Self-defined variables
Self-defined variables are created (and eventually initialized) in the NC-main or a sub program after the program name in a declarations block which starts with #VAR and is closed by #ENDVAR. The following syntax is used for creation:
For compatibility to older versions V.P and V.S variables may also be created outside the declarations block. The creation is then done implicitly during the first write access to the variable. But V.L variables and variable arrays must always be created in a declarations block. To the better overview the initialization of a parameter array can be written over several NC blocks by using the \-character. The following syntax is used for creating:
#VAR Start of declaration block
:
: Declaration and initialisation part
:
#ENDVAR End of declaration block
Programming example
%prog_name
:
#VAR
V.P.ARRAY_1[3][6] = [10,11,12,13,14,15, \
20,21,22,23,24,25, \
30,31,32,33,34,35 ]
V.L.MY_ARRAY[3][6] = [10,11,12,13,14,15, 20,21,22,23,24,25, 30,31,32,33,34,35]
V.P.VAR_1
V.L.VAR_1
V.S.VAR_1
#ENDVAR
Self-defined variable and variable arrays can also be deleted in the NC-program. For that, the #DELETE command is provided with the following syntax.
#DELETE V. <name> {,V.<name>}
Programming example
#DELETE V.P.ARRAY_1, V.L.MY_ARRAY, V.P.VAR_1, V.L.VAR_1, V.S.VAR_1
Furthermore, the SIZEOF and the EXIST function (see chapter 2.6.1.3) are used to determine the dimensions size of variable arrays and for checking the existence of self-defined variables.
Programming example
By the EXIST-request on a self-defined V.S.-array variable (any valid index) it is checked, whether this variable has already been defined in a previous part program or if this variable still has to be defined.
...
N10 $IF EXIST[V.S.EXAMPLE[0]] == TRUE
N20 V.S.EXAMPLE[2] = 10 (enter value for V.S-variable[2])
N30 $ELSE
N40 #VAR
N50 V.S.EXAMPLE[5] = [1,2,3,4,5 ]
N60 #ENDVAR
N60 $ENDIF
...
M30