1.5 Variable definition
1.5.1 Definition format and variable type
A variable name contains letters, digits, and underscores, and can only begin with the alphabet.
Definition format of variable:
DEF type name [= value]
Example:
DEF INT ANZAHL
DEF INT ANZAHL = 7
Continuous variables can also be defined and assigned:
DEF type name 1 [=value1], name 2 [=value 2], name 3 [=value 3],……
Example:
DEF REAL HH1=1, HH2=2, HH3=3
Variables type includes several kinds as the following:
INT Integer type, meaning integer numbers
REAL Real type, meaning number with a decimal, including integer
BOOL Boolean, the value is ‘TRUE’ or ‘FALSE’
CHAR Character, a single character corresponding to ASCII codes, marking with single quotation
STRING String, consist of a number of characters, marking with double quotation
AXIS Axis type, representing address of axsis, 0 for X axis, 1 for Y axis, 2 for Z axis
Example:
DEF CHAR FORM = 'A'
DEF CHAR FORM [2] = ('A','B')
DEF STRING MDG = “ALARMING”
1.5.2 Array definition
Programming:
DEF CHAR NAME [N, M]
DEF INT NAME [N, M]
DEF REAL NAME [N, M]
DEF AXIS NAME [N, M]
DEF STRING NAME [M]
DEF BOOL NAME [N, M]
Explanations:
Array can define up to two dimensions, but the array variable of string type can only be defined as one dimension. The first array element from the address [0, 0], for example, when the array is a two-dimensional array of 3 × 4, the maximum array address may be [2, 3].
Array element can be assigned when the program runs, it can also be assigned while the definition of the array.
When array defining:
DEF REAL FELD [2, 3] = (10, 20, 30, 40)
When program running:
A single unit can be assigned.
Example:
FELD [0, 0] = 10
FELD [0, 1] = 20
……
It can also be continuous assignment, example:
FELD [0, 0] = SET (10, 20, 30, 40)
How many initial values are programmed, there are the same number of array elements being assigned, unassigned unit will be automatically filled with 0. If the amount of assignment
exceeds the amount of array elements, it would alarm. Using "SET" keyword can assign continuously from the specified unit.
In addition, you can use "REP" keyword to the array with the same value, the example in the array definition:
DEF REAL FELD [10, 3] = REP (9.9)
In above definition, all array elements are defined in 9.9. Or you can define when the program is running:
DEF REAL FELD [10, 3]
FELD [0, 0] = REP (100)
FELD [5, 0] = REP (-100)
The first half of the array is 100, the second half is -100.