What is an array?An array is like a variable, but whereas a vaiable holds just one value at a time, an array can hold many values at the same time. To be able to identify exactly which of the values we wish to access at any one time, we refer to the number of the value within the array. This number is called the index and the value the index refers to within an array is called the element. In XCSB the element 3 of an array called FRED would be refered to as FRED. The index can itself be a variable so XCSB will allow references to elements such as FRED[J].
XCSB will allow an array element to be used anywhere where it will allow a simple variable.e.g. X = BERT + 1 X = FRED + 1 BERT = X + 10 FRED = X + 10
Many other PIC BASIC compilers do not support arrays or impose severe restrictions on their use.
Arrays are indespensible as buffers and lookup tables.
What is a data (RAM) array?A data array (sometimes refered to as a RAM array), is an array that can have its elements modified like any other variable.
The ability to specifically place an array in the PICs code space, removes the need to copy data from the non-volatile program area of the PIC into a RAM array when the PIC starts up, while keeping the benefits of random data access inherent in array lookups.
Some PIC BASIC compilers do not have code space arrays. Instead they rely on DATA and READ statements to scan sequentially through code space data. Unlike the values of an XCSB code space array which can be used directly in any expression, the data READ from a DATA statement needs to be loaded into a seperate variable before it can be used.