﻿ REUSE()

# REUSE()

The REUSE() function determines how arithmetic operators applied to numeric arrays handle unequal numbers of fields, values or subvalues. It can also be used with arguments to the multivalue functions.

Format

REUSE(dyn.array)

where

 dyn.array is a dynamic array.

Arithmetic operators such as addition applied to numeric arrays (dynamic arrays where each element is numeric) operate on each field, value or subvalue in turn. Where the layout of fields, values and subvalues in the two numeric arrays is identical there is no difficulty, each element of one array being added (etc) to its corresponding element from the second array.

If the arrays are of different structure, such as one having more fields than the other or more values in one field than the corresponding field of the other array, the arithmetic operators normally use a default value for the missing item. This value is zero except for the divisor of a division operation which defaults to one.

For dynamic arrays used in the multivalue functions, missing items default to a null string.

The REUSE() function causes the previous field, value or subvalue to be reused in place of this default value where array structures do not match. The REUSE() function applies only to values in expressions; its effect cannot be assigned to a variable but it can be used to qualify an argument in a subroutine or function call.

Examples

A = "1" : @FM : "2" : @FM : "3"

B = "10" : @FM : "20"

C = A + B

D = A + REUSE(B)

In this example, C is set to "11FM22FM3" and D to "11FM22FM23". The REUSE() function causes the final field of B to be reused in the addition with field 3 of A.

A = "1" : @FM : "2" : @FM : "3"

C = A + 10

D = A + REUSE(10)

This example is similar except that numeric array B has been replaced by a simple numeric constant which can be considered to be a single element numeric array.

In this case, C is set to "11FM2FM3" and D to "11FM12FM13".

A = "1":@FM:"2":@VM:"3":@VM:"4":@FM:"5":@VM:"6":@VM:"7":@FM:"8"

B = "10":@FM:"20":@FM:"30":@VM:"40"

C = A + B

D = A + REUSE(B)

In this example individual fields and values of A and B are matched into pairs for the addition operations.

C is set to "11FM22VM3VM4FM35VM36VM7FM8".

D is set to "11FM22VM23VM24FM35VM36VM37FM48".