
PROGRAMMING
B–62094E/04
15. CUSTOM MACRO
135
Variables are classified into four types by variable number.
Table 15.1 Types of variables
Variable
number
Type of
variable
Function
#0 Always
null
This variable is always null. No value can
be assigned to this variable.
#1 – #33 Local
variables
Local variables can only be used within a
macro to hold data such as the results of
operations. When the power is turned off,
local variables are initialized to null. When
a macro is called, arguments are assigned
to local variables.
#100 – #199
#500 – #699
Common
variables
Common variables can be shared among
different macro programs. When the power
is turned off, variables #100 to #199 are
initialized to null. Variables #500 to #699
hold data even when the power is turned
off.
#1000 – System
variables
System variables are used to read and
write a variety of NC data items such as the
current position and tool compensation val-
ues.
To reference the value of a variable in a program, specify a word address
followed by the variable number. When an expression is used to specify
a variable, enclose the expression in brackets.
Example: G01X[#1+#2]F#3;
A referenced variable value is automatically rounded according to the
least input increment of the address.
Example:
When G00X#1; is executed on a 1/1000–mm CNC with 12.3456
assigned to variable #1, the actual command is interpreted as
G00X12.346;.
To reverse the sign of a referenced variable value, prefix a minus sign (–)
to #.
Example: G00X–#1;
When an undefined variable is referenced, the variable is ignored up to an
address word.
Example:
When the value of variable #1 is 0, and the value of variable #2 is
null, execution of G00X#1Y#2; results in G00X0;.
D Types of variables
D Referencing variables