VXi VT1529A/B 사용자 설명서

다운로드
페이지 529
Creating and Running Algorithms   217
Program Structure and Syntax
In this section, the portion of the 'C' programming language that is directly 
applicable to the VT1422A' Algorithm Language will be discussed. To do 
this, the 'C' Algorithm Language elements will be compared with equivalent 
BASIC language elements.
Declaring Variables
In BASIC, the DIM statement is usually used to name variables and allocate 
space in memory for them. In the Algorithm Language, the variable type and 
a list of variables is specified:
BASIC
'C'
DIM a, var, array(3)
static float a, var, array[ 3 ];
Here, three variables are declared. Two simple variables: a and var and a 
single dimensioned array: array.
Comments:
Note that the 'C' language statement must be terminated with the 
semicolon ";".
Although in the Algorithm Language all variables are of type float, 
they must be explicitly declared as such.
All variables in an algorithm are static. This means that each time the 
algorithm is executed, the variables "remember" their values from the 
previous execution. The static modifier must appear in 
the declaration.
Array variables must have a single dimension. The array dimension 
specifies the number of elements. The lower bound is always zero (0) 
in the Algorithm Language. Therefore, the variable My_array from 
above has three elements: My_array [0] through My_array[2].
Assigning Values
BASIC and 'C' are the same here. In both languages, the symbol "=" is used 
to assign a value to a simple variable or an element of an array. The value 
can come from a constant, another variable or an expression. Examples:
a = 12.345;
a = My_var;
a = My_array[ 2 ];
a = (My_array[ 1 ] + 6.2) / My_var;
 NOTE
In BASIC, the assignment symbol "=" is also used as the comparison 
operator "is equal to." For example; IF a=b THEN ... . It will be seen later in 
this chapter that 'C' uses a different symbol for this comparison.