Assignment of Array Entries
Like variables, each array element can be assigned a value. Assigned values can be numbers or
returned values from instructions, functions and keywords.
Array elements are addressed starting at count 0. For example the first element in the POSX array
(defined with the DM command, DM POSX[7]) would be specified as POSX[0].
Values are assigned to array entries using the equal sign. Assignments are made one element at a
time by specifying the element number with the associated array name.
NOTE: Arrays must be defined using the command, DM, before assigning entry values.
Examples:
DM SPEED[10]
Dimension Speed Array
SPEED[1]=7650.2 Assigns
the
second element of the array, SPEED the value 7650.2
SPEED[1]=
Returns array element value
POSX[10]=_TPX
Assigns the 11th element of the array POSX the returned value from the tell
position command.
CON[2]=@COS[POS]*2
Assigns the third element of the array CON the cosine of the variable POS
multiplied by 2.
TIMER[1]=TIME
Assigns the second element of the array timer the returned value of the TIME
keyword.
Using a Variable to Address Array Elements
An array element number can also be a variable. This allows array entries to be assigned
sequentially using a counter.
For example:
#A Begin
Program
COUNT=0;DM POS[10]
Initialize counter and define array
#LOOP Begin
loop
WT 10
Wait 10 msec
POS[COUNT]=_TPX Record
position into array element
POS[COUNT]= Report
position
COUNT=COUNT+1 Increment
counter
JP #LOOP,COUNT<10
Loop until 10 elements have been stored
EN End
Program
The above example records 10 position values at a rate of one value per 10 msec. The values are
stored in an array named POS. The variable, COUNT, is used to increment the array element
counter. The above example can also be executed with the automatic data capture feature
described below.
Uploading and Downloading Arrays to On Board Memory
Arrays may be uploaded and downloaded using the QU and QD commands.
QU
array[],start,end,delim
QD
array[],start,end
where array is an array name such as A[].
Start is the first element of array (default=0)
End is the last element of array (default=last element)
DMC-1600
Chapter 7 Application Programming
•
141