Self-defined variables (#VAR, #ENDVAR, #DELETE)
Self-defined variables are created and initialised as required in the NC main program or subroutine after the program name in a declaration block which starts with #VAR and ends with #ENDVAR .
![]() | Self-defined variables have prefix identifier V.P. , V.S. and V.L. They may be assigned values in REAL format. As of Build V2.11.2032.08 self-defined variables are available with the prefix identifier V.CYC.. |
Syntax of Creating a declaration block for self-defined variables: | |
#VAR | Start of declaration block |
: |
|
: | Declaration and initialisation part |
: |
|
#ENDVAR | End of declaration block |
Due to the introduction of V.CYC. variables, the following extensions are available for all types of self-defined variables (as of: V2.11.2032.08, V2.11.2832.00, V3.1.3079.41, V3.1.3107.30)
Besides specifying the variable name, the declaration also includes a definition of the data type and an initial value. The variable is assigned the initial value of each data type without assigning an initial value. If a data type is not specified, the variable is always created in REAL format.
Syntax of the declaration and initialisation: |
V.P | S | L | CYC.<name> : <data_type> = <initial:value> | "<initial_string>" |
<name> | User-defined name of the self-defined variable |
<data_type> | Data type identifiers (optional): BOOLEAN SGN08, UNS08 SGN16, UNS16 SGN32, UNS32 REAL64 STRING[i] where <i>:= 0..126 |
<Initial_value>, "<Initial_string>" | Initial value or string of the variable (optional) depending on data type |
Programming Example
![]() | 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.
Syntax : |
#DELETE V.<name> {, V.<name>} |
Programming Example
In addition, the SIZEOF and EXIST functions are provided (see Section Arithmetical expressions <expr>) to determine the dimensional size of variable arrays and check for the existence of self-defined variables.