Galil DMC-1700 Manual De Usuario

Descargar
Página de 253
158 • Chapter 7 Application Programming DMC-1700/1800 
DM POSX[7] 
Defines an array names POSX with seven entries  
DM SPEED[100] 
Defines an array named speed with 100 entries  
DM POSX[0] 
Frees array space 
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 first element of the array, SPEED the value 7650.2 
SPEED[1]= 
Returns array element value 
POSX[10]=_TPX 
Assigns the 10
th
 element of the array POSX the returned value from the tell 
position command. 
CON[2]=@COS[POS]*2 
Assigns the second element of the array CON the cosine of the variable POS 
multiplied by 2. 
TIMER[1]=TIME 
Assigns the first 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 f
eature 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[].