The ELEM() or ELEMS() built-in functions return the number of elements in the Session Variable Array.
The ELEM() built-in function returns the number of independent values stored in the Session Variable. Multiple values may be stored in Session Variables using the SELECT INTO with multiple rows returned, or using the (a) operation extender on the
select baldue INTO &DUE
WHERE BALDUE > 0;
for &i = 1 to elem(&due);
if (&due[&i] > 1000); // To high a balance?
// send out Payment Due notice
In this example the ELEM(&DUE) is performed once for each value stored in the &DUE Session Variable. That variable's values are loaded by the SELECT statement. If multiple rows are returned each value is stored in the &DUE variable separately,
creating an array-like variable. The FOR loop is performed for the number of elements in that variable. The variable &I is automatically declared and is automatically incremented on each pass through the for loop.
To access individual values of the Session Variable, the square brackets are used as an "array subscript" syntax. For example &MYARR references the 3rd value in the &MYARR Session Variable.