38196-8000
MACROS
June 1999
This executes the statements between DOn and ENDn as long as the conditional expression evaluates to
TRUE. The brackets in the expression are necessary. If the expression evaluates to FALSE, then the block
after ENDn is executed next. WHILE can be abbreviated to WH. The DOn-ENDn portion of the statement is a
matched pair. The value of n is 1..3. This means that there can be no more than three nested loops per subrou-
tine. A nest is basically a loop within a loop. A good example of how nesting of WHILE loops can be used is in
defining a matrix.
#101= 3 ;
#102= 4 ;
G0 X#101 Y4. ;
F2.5 ;
WH [ #101 GT 0 ] DO1 ;
#102= 4 ;
WH [ #102 GT 0 ] DO2 ;
G81 X#101 Y#102 Z-0.5 ;
#102= #102 - 1 ;
END2 ;
#101= #101 - 1 ;
END1 ;
;
M30 ;
This program drills a 3 x 4 matrix hole pattern.
Although nesting of WHILE statements can only be nested to three levels, there really is no limit since each
subroutine can have up to three levels of nesting. If there ever is a need to nest to a level greater than 3, then
the segment containing the three lowest levels of nesting can be made into a subroutine thus overcoming the
limitation.
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 ;
This is valid code.
You can use GOTO to jump out of a region encompassed by a DO-END, but you can not use a GOTO to jump
into it. Jumping around inside a DO-END region using a GOTO is allowed.