spec

Software for Diffraction

2.3.3.1. - Associative Arrays



Associative arrays have been around since the earliest versions of spec. For associative arrays, the array index expression can be any numeric or string-valued constant or expression, although the internal code always uses the string value. Thus A["12"] refers to the same element as A[12]. Elements of associative arrays can contain numbers or strings. Currently, all built-in global arrays, such as those that hold motor positions and scaler counts, are associative arrays.

Associative arrays may also be two dimensional, as of release 4.01.11. Internally, the two array indices for each element are stored as a single string formed using the string value of the first index, followed by the character \034, followed by the string value of the second index. You can access such a 2D array element using a single index constructed according to the above recipe. That is, arr["list"]["one"] refers to the same item as arr["list\034one"].