Self-defined variables

Self-defined variables (V.P., V.S., V.L.) are created (and possibly initialised) in the NC main or subroutine after the program name in a declaration block which starts with #VAR and ends with #ENDVAR.

Notice

notice

The self-defined variables V.P., V.S. and V.L. may be assigned values in REAL format.

Self-defined variables must be created in a declaration block. For a better overview, initialisation of a variable array can be written across several NC lines using the "\” character. The following syntax is used for the creation operation:

#VAR                                            Start of declaration block

:

:                                                    Declaration and initialisation part

:

#ENDVAR                                     End of declaration block

Programing Example

prg_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

Notice

notice

Access to array variables starts with index 0. In the above example, access V.L.MY_ARRAY[0][5] then supplies the value 15.

Self-defined variables and variable arrays can also be deleted in the NC program. The #DELETE command is provided for this with the following syntax.

#DELETE V.<name> {, V.<name>}

Programing Example

prg_example

#DELETE V.P.ARRAY_1, V.L.MY_ARRAY, V.P.VAR_1, V.L.VAR_1, V.S.VAR_1

In addition, the SIZEOF and EXIST functions are provided (see Section Arithmetic expressions <expr>) to determine the dimensional size of variable arrays and check for the existence of self-defined variables.

Programing Example

prg_example

The EXIST request for a self-defined V.S. array variable (any valid index) checks whether this variable was already defined in a previous NC program or if this variable must still be defined:

N10 $IF EXIST[V.S.EXAMPLE[0]] == TRUE

N20  V.S.EXAMPLE[2] = 10

(Assign 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