REUSE function
Syntax
REUSE (expression)
Description
Use the REUSE function to specify that the value of the last field, value, or subvalue be reused in a dynamic array operation.
expression is either a dynamic array or an expression whose value is considered to be a dynamic array.
When a dynamic array operation processes two dynamic arrays in parallel, the operation is always performed on corresponding subordinate values. This is true even for corresponding fields, each of which contains a single value. This single value is treated as the first and only subvalue in the first and only value in the field.
A dynamic array operation isolates the corresponding fields, values, and subordinate values in a dynamic array. It then operates on them in the following order:
- The subordinate values in the values
- The values in the fields
- The fields of each dynamic array
A dynamic array operation without the REUSE function adds zeros or empty strings to the shorter array until the two arrays are equal. (The DIVS function is an exception. If a divisor element is absent, the divisor array is padded with ones, so that the dividend value is returned.)
The REUSE function reuses the last value in the shorter array until all elements in the longer array are exhausted or until the next higher delimiter is encountered.
After all subordinate values in a pair of corresponding values are processed, the dynamic array operation isolates the next pair of corresponding values in the corresponding fields and repeats the procedure.
After all values in a pair of corresponding fields are processed, the dynamic array operation isolates the next pair of corresponding fields in the dynamic arrays and repeats the procedure.
If expression evaluates to the null value, the null value is replicated, and null is returned for each corresponding element.
Example
B = (1:@SM:6:@VM:10:@SM:11)
A = ADDS(REUSE(5),B)
PRINT "REUSE(5) + 1:@SM:6:@VM:10:@SM:11 = ": A
*
PRINT "REUSE(1:@SM:2) + REUSE(10:@VM:20:@SM:30) = ":
PRINT ADDS(REUSE(1:@SM:2),REUSE(10:@VM:20:@SM:30))
*
PRINT "(4:@SM:7:@SM:8:@VM:10)*REUSE(10) = ":
PRINT MULS((4:@SM:7:@SM:8:@VM:10 ),REUSE(10))
This is the program output:
REUSE(5) + 1:@SM:6:@VM:10:@SM:11 = 6S11V15S16
REUSE(1:@SM:2) + REUSE(10:@VM:20:@SM:30) =
11S12V22S32
(4:@SM:7:@SM:8:@VM:10)*REUSE(10) = 40S70S80V100