Flexible NC programming
1.2 Variable definition (DEF user-defined variables LUD, GUD, PUD)
Job planning
1-6 Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
Example: Redefine local (LUD) and program-global user variables (PUD)
If they are defined in the main program, they will also be valid at all levels of the subroutines
called. They are created with parts program start and deleted with parts program end or
reset.
If machine data $MN_LUD_EXTENDED_SCOPE is set, it is not possible to define a variable
with the same name in the main and subroutines.
$MN_LUD_EXTENDED_SCOPE=1
PROC MAIN ;Main program
DEF INT VAR1 ;PUD definition
... ;Subroutine call
SUB2
...
M30
PROC SUB2 ;Subroutine SUB2
DEF INT VAR2 ;LUD DEFINITION
...
IF (VAR1==1) ;Read PUD
VAR1=VAR1+1 ;Read & write PUD
VAR2=1 ;Write LUD
ENDIF ;Subroutine call
SUB3
...
M17
PROC SUB3 ;Subroutine SUB3
...
IF (VAR1==1) ;Read PUD
VAR1=VAR1+1 ;Read & write PUD
VAR2=1 ;Error: LUD from SUB2 not known
ENDIF
...
M17
Variable names
A variable name consists of up to 31 characters. The first two characters must be a letter or
an underscore.
The "$" sign can not be used for user-defined variables because it is used for system
variables.