Skip to main content


Reuses a value when comparing two dynamic arrays of different lengths.




dynarray An expression that resolves to a dynamic array. This argument can be a dynamic array of one element—a string or numeric expression.


The REUSE function is used in combination with MVBasic functions that compare the elements of two dynamic arrays. Its most common use is to provide a corresponding element value when comparing dynamic arrays of different lengths. REUSE provides the needed element values for the shorter of the two dynamic arrays by reusing the last element value as the value for all subsequent element comparisons.

REUSE can be used with the following MVBasic functions: ADDS (addition), SUBS (subtraction), MULS (multiplication), DIVS (division), MODS (modulo division), PWRS (exponentiation), EQS (equal to), NES (not equal to), GTS (greater than), GES (greater than or equal to), LTS (less than), LES (less than or equal to), CATS (concatenate), SPLICE (concatenate with delimiter), ANDS (logical AND), and ORS (logical OR).

Specifying REUSE has no effect when the two dynamic arrays are of the same size, or if REUSE is specified for the larger of the two dynamic arrays.

If dynarray is set to a literal, it is treated as a dynamic array with one element. In other words, the literal is compared to every element in the other dynamic array.

If REUSE is not used when comparing dynamic arrays of different lengths, a value is provided for the elements without a match. In most cases these elements are compared with either the null string (for string comparisons) or with 0 (for numeric comparisons). Note however that the DIVS function supplies a value of 1 for missing divisor elements to prevent division by zero errors.


INFORMATION, jBASE, PIOpen, Prime, and UniData set $OPTIONS VEC.MATH. When the $OPTIONS VEC.MATH is set, REUSE can use operator symbols to perform the five basic arithmetic operations on dynamic arrays. The + operator is equivalent to the ADDS function. The – operator is equivalent to the SUBS function. The * operator is equivalent to the MULS function. The / operator is equivalent to the DIVS function. The ** operator is equivalent to the PWRS function. These operators perform vector arithmetic when supplied dynamic array arguments, and perform simple arithmetic operations when supplied numeric arguments.


The following example gives the shipping weight of various items. The items (widget) vary in weight, but the packaging (box) is always the same weight:

PRINT shipwt
  ! Returns 5.3v4.3v5.8v3.8v6.3v5.3v4.3

The following example concatenates the string value elements of two dynamic arrays. In this case, the qrtrs dynamic array is static; it always has four values, while the qpaid dynamic array grows as quarterly payments are posted. By making its last element value “unpaid”, the resulting paidstatus dynamic array always has a payment status for each quarter:

paidstatus = CATS(qrtrs,REUSE(qpaid))
PRINT paidstatus
  ! returns Q1-$100vQ2-$150vQ3-unpaidvQ4-unpaid

The following example uses REUSE to calculate bonuses based on salary. The policy of this organization is to give its three highest-paid employees (the partners) a bonus of 1.5% of salary, and all other employees a bonus of 2% of salary:


See Also

FeedbackOpens in a new tab