20 Custom Macro
Including only the interpolations, the sequence of executions will be
Level of call | ||||
))) Level 0 | ||||
))) Level 1 | ||||
| ||||
| ))) Level 2 | |||
|
|
|
Of the numbers in brackets, the first and the second ones are the numbers of the programs and block being executed, respectively.
Instruction G67 specified in block N14 will cancel the macro called in block N12 (O0003); the one specified in block N15 will cancel the macro called in block N10 (O0002).
In the case of multiple calls of macros type G66.1, first the last specified macro will be called in entering each block (treating the addresses of the particular block as arguments), then the previously specified macro will be called, entering the blocks of that macro and treating them as arguments.
If another macro is called again from a macro, the levels of local variables will also increase with the macro levels.
main program | macro | macro | macro | macro |
level 0 | level 1 | level 2 | level 3 | level 4 |
| O_____ | O_____ | O_____ | O_____ |
G65 P | G65 P | G65 P | G65 P |
|
| M99 | M99 | M99 | M99 |
local variables |
|
|
|
|
level 0 | level 1 | level 2 | level 3 | level 4 |
#1 | #1 | #1 | #1 | #1 |
| : | : | : | : |
#33 | #33 | #33 | #33 | #33 |
When the first macro is called, the local variables of the main program will be stored (#1 through #33), and the local variables at level 1 will assume the argument values specified in the call. If another macro is called from the first level, the local variables of the first level will be stored (#1 through #33), and the local variables on the second level will assume the argument values specified in the call. In the case of multiple call, the local variables of the previous level will be stored and the local variables on the next level will assume the argument values specified in the call. In the case of M99, returning from the called macro to the calling program, the local variables stored on the previous level will be restored in the same states they were at the time of being stored during the call.
171