101
96-8000 rev R June 2007
Macros
If two separate WHILE loops are in a subroutine, they can use the same nesting index. For example:
#3001=0 (WAIT 500 MILLISECONDS);
WH [#3001 LT 500] DO1;
END1;
<Other statements>
#3001=0 (WAIT 300 MILLISECONDS) ;
WH [#3001 LT 300] DO1 ;
END1 ;
You can use GOTO to jump out of a region encompassed by a DO-END, but you cannot use a GOTO to jump into it.
Jumping around inside a DO-END region using a GOTO is allowed.
An infinite loop can be executed by eliminating the WHILE and expression. Thus,
DO1;
<statements>
END1;
Executes until the RESET key is pressed.
CAUTION! The following code can be confusing: WH [#1] D01;
END1;
In the this example, an alarm results indicating no “Then” was found; “Then” refers to the D01. Change D01 (zero) to
DO1 (letter O).
G65 MACRO SUBROUTINE CALL
G65 is the command that calls a subroutine with the ability to pass arguments to it. The format follows.
G65 Pnnnn [Lnnnn] [arguments];
Anything italicized in square brackets is optional. The G65 command requires a P address corresponding to a
program number currently in the control’s memory. When the L address is used the macro call is repeated the
specified number of times.
In Example 1, subroutine 1000 is called once without conditions passed to the subroutine. G65 calls are similar to,
but not the same as, M98 calls. G65 calls can be nested up to 9 times, which means, program 1can call program 2,
program 2a nd call program 3 and program 3 can call program 4.
Example 1: G65 P1000; (Call subroutine 1000 as a macro)
M30; (Program stop)
O1000; (Macro Subroutine)
...
M99; (Return from Macro Subroutine)
In Example 2, subroutine 9010 is designed to drill a sequence of holes along a line whose slope is determined by
the X and Y arguments that are passed to it in the G65 command line. The Z drill depth is passed as Z, the feed rate
is passed as F, and the number of holes to be drilled is passed as T. The line of holes is drilled starting from the
current tool position when the macro subroutine is called.