
16.CUSTOM MACRO PROGRAMMING B-63944EN/02
- 350 -
- Local variable (#1-#33)
A local variable is a variable that is used in a macro locally. That is,
local variable #i used by a macro called at a certain time is different
from that used by a macro called at another time, regardless of
whether the two macros are the same. Therefore, for example, when
macro A calls macro B during multiple calls or the like, it is
impossible for macro B to corrupt a local variable used by macro A by
erroneously using the variable.
A local variable is used to pass arguments. For information on
correspondence between arguments and addresses, see the section
about macro calling commands. The initial state of a local variable
to which no arguments are passed is <null> and the user can freely use
the variable. The attribute of a local variable is READ/WRITE
enabled.
- Common variable (#100-#199, #500-#999)
A common variable is shared among the main program, subprograms
called by the main program, and macros while a local variable is used
locally in a macro. That is, #i used by a macro is the same as that used
by another macro. Therefore, a resultant common variable obtained by
using a macro can be used by another macro. The attribute of a
common variable is basically READ/WRITE enabled. However, the
common variable can be protected (its attribute is set to READ only) by
specifying its variable number using parameters No.6031 and No.6032.
A common variable can be freely used by the user even when its usage
is not defined by the system. The number of common variables can be
specified by selecting one of the following options.
(a) 100 common variables (specified only with the custom macro
option)
The common variables #100 to #149 and #500 to #549 can be
used. The variables #100 to #149 are cleared during
power-down, but the variables #500 to #549 are retained during
power-down.
(b) 600 common variables (specified with the custom macro
option or custom macro common variable addition option)
The common variables #100 to #199 and #500 to #999 can be
used. The variables #100 to #199 are cleared during
power-down, but the variables #500 to #999 are retained during
power-down.
- Write protection of a common variable
Multiple common variables (#500 to #999) can be protected (their
attributes are set to READ only) by setting variable numbers in
parameters No.6031 and No.6032. This protection is enabled for
both Input/All Clear by MDI on the macro screen and write operation
by a macro program. If the NC program specifies WRITE operation
(used in the left side) for a common program in the set range, an alarm
PS0116 is issued.