This document discusses the differences between macro calls and subprogram calls in CNC programming. It explains that with macro calls, the local variables are reinitialized each time, so #1 is set to 1 with each call of program 00015. With subprogram calls, the local variables persist across calls, so #1 from the calling program is modified by program 00014 and retains the value of 7 after three executions. The final values stored by #500 and #501 after three calls are also reported.
This document discusses the differences between macro calls and subprogram calls in CNC programming. It explains that with macro calls, the local variables are reinitialized each time, so #1 is set to 1 with each call of program 00015. With subprogram calls, the local variables persist across calls, so #1 from the calling program is modified by program 00014 and retains the value of 7 after three executions. The final values stored by #500 and #501 after three calls are also reported.
This document discusses the differences between macro calls and subprogram calls in CNC programming. It explains that with macro calls, the local variables are reinitialized each time, so #1 is set to 1 with each call of program 00015. With subprogram calls, the local variables persist across calls, so #1 from the calling program is modified by program 00014 and retains the value of 7 after three executions. The final values stored by #500 and #501 after three calls are also reported.
(This macro call is independent of the call in the
previous block. So, 00016 is executed once, with
#1 again initially set to 1, even if #1 of the previous execution contained a different value. In fact, #1 of the previous execution carries no meaning now) G65 P0016 A1; (Same as above) #503 = #1; (Since the subprogram call modified the value stored in #1 to 7, #503 would store 7. A macro call has no effect on the local variables of the calling program) M30; (Execution end and control reset) 00014; (Program number 14) #1 = #1 + 2; (Since this program has been called as a subprogram, #1 used here is the same as #1 of the calling program 00013. Since every execution of this program adds 2 to the value stored in #1, the final value becomes 7, after three executions) #500 #1; (#500 stores 3 after the first execution, 5 after the second, and 7 after the third and final execution) M99; (Return to the calling program, after all the specified number of repetitions are over. After the return, #1 of the calling program would contain 7, since it is the same as #1 of this subprogram) 00015; (Program number 15) #1 = #1 + 2. (Since this program has been called as a macro, #1 used here is different from #1 of the calling program 00013. The macro call assigns a value of 1 to the macro variable #1, in the beginning of the first call of this program. The repeated calls use the updated values of #1. Since every execution of this program adds 2 to the value stored in #1, the final value becomes 7, after three executions) #501 #1; (#501 stores 3 after the first execution, 5 after the second, and 7 after the third and final execution) M99; (Return to the calling program, after all the specified number of repetitions are over. Since #1 of this program and #1 of the calling program are different