Positron Compiler Documentation

Finer points of array variables.

Positron16 · Revision 1.1.3.5 · PDF page 48

When an array is created, the compiler creates each of its elements as an independent variable that has the same width and sign as the parent array. For example:

Dim MyByteArray[10] as Byte

Will also produce 10 separate variables named:

MyByteArray_0 MyByteArray_1 MyByteArray_2 MyByteArray_3 MyByteArray_4 MyByteArray_5 MyByteArray_6 MyByteArray_7 MyByteArray_8 MyByteArray_9

Notice the underscore after the name of the array, and preceding the element’s positional value within the array. Each of these elements is an unsigned Byte variable in its own right, and can be accessed collectively or independently. The same principle applies to all array types supported by the compiler.

Note that this differs from Positron8 for 8-bit devices in that the separation between the array name and the element number is a hash '# 'in Positron8, 8-bit, but this is not allowed in the 16bit assembler, therefore, they are underscores in Positron16.

Block Array Assigning

One array can be loaded into another array by issuing the names of the arrays but without the square brackets. For example:

Dim bSourceArray[10] as Byte = 1,2,3,4,5,6,7,8,9,10
Dim bDestArray[10] as Byte

bDestArray = bSourceArray ' Copy the contents of bSourceArray into bDestArray

If different type arrays are used as the assignment or the source, truncation or extrapolation will take place. If the assignment array has fewer elements than the source array, only the elements that will fit into the assignment array will be copied.

View original PDF page 48Open page in PDFOriginal PDF page 48