ARAP handles arrays as a special case of an otherwise normal Global Variable. Local Variables and Pre-Defined Variables cannot be used to manipulate arrays.

Arrays are stored as a "delimited" string. The current value of the ARRAYDELIMITER variable is used to indicate the delimiter. The default delimiter is the "return" character (ASCII 13) - in which case the "linefeed" character is ignored. Commonly used delimiters are comma, space, and tab characters. If the delimiter is a space, the non-blocking space character (hex A0) is also used. If the array delimiter has more than one character, only the first character is used,

The array index starts with 1. Array index 0 returns the number of elements in the array. Accessing an array element that does not exist will return the value "BAD_ARRAY_INDEX". If the array index is not a valid integer a value of "BAD_VARIABLE" is returned.

Since variables are just strings, array elements can store any data type (boolean, string, integer, floating point number, etc.).

Notes:

  • Individual array elements cannot be set if the array variable does not previous exist.
  • You cannot set an array element whose index is larger than the number of elements currently in the array. Set the size of an array first (eg. ARRAYNAME[0]= 5)

Example array usage (with an array named ARRAYNAME):

Set the current array delimiter (eg. to tab):

ARRAYDELIMITER= $TAB

Get number of array elements:

       $ARRAYNAME[0]

Get value of element 'index':

       $ARRAYNAME[index]

Get value of element from variable INDEX:

$ARRAYNAME[$INDEX]

Set the value of constant element (eg. element 5):

       ARRAYNAME[5]= value

Set the value of variable element (eg. element INDEX):        

ARRAYNAME[$INDEX]= value

Setting the number of elements in an array (note, this clears the array values):

       ARRAYNAME[0]= num_elements

Setting several elements of an array in one step (eg. with comma delimiter):

       ARRAYNAME= 1,2,3,4,5