12.07.2015 Views

spec - Local Sector 7 web page

spec - Local Sector 7 web page

spec - Local Sector 7 web page

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ArraysArrays are formed using square brackets, as in identifier [ expression ] . <strong>spec</strong> hastwo kinds of arrays: associative arrays and data arrays.Associative ArraysAssociative arrays have been around since the earliest versions of <strong>spec</strong>. For associativearrays, the array index expression can be any numeric or string-valued constantor expression, although the internal code always uses the string value. ThusA["12"] refers to the same element as A[12] . Elements of associative arrays cancontain numbers or strings. Currently, all built-in global arrays, such as those thathold motor positions and scaler counts, are associative arrays.Associative arrays may also be two dimensional, as of release 4.01.11. Internally, thetwo array indices for each element are stored as a single string formed using thestring value of the first index, followed by the character \034 ,followed by the stringvalue of the second index. Youcan access such a 2D array element using a singleindex constructed according to the above recipe. That is, arr["list"]["one"] refersto the same item as arr["list\034one"] .Data ArraysThe second kind of array is the data array introduced in <strong>spec</strong> release 4.00. The dataarrays store and manipulate their contents far more efficiently than associativearrays, and also use a far more intuitive syntax than the data group facility(described later) for which they are an alternative. For data arrays, the array indexmust be a number, and array elements are numbered consecutively starting at zero.Data arrays must be explicitly declared using the array keyword. The data values ofdata-array elements are not currently saved in the user’s state file, unlike associativearray elements and the contents of data groups.INTERIM WORK-IN-PROGRESS (8/16/01) NOT FOR GENERAL DISTRIBUTION REFERENCE MANUAL 47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!