Work preparation
3.2 Subprogram technique
Actual parameters
When a subprogram is called, absolute values or variables (known as actual parameters) have
to be transferred to it.
As such, the actual parameters assign up-to-date values to the interface of the subprogram
when the latter is called.
Example:
Program code
N10 DEF REAL WIDTH
N20 WIDTH=20.0
N30 CONTOUR(5.5, WIDTH)
...
N100 M30
3.2.1.6
Parameter transfer
Definition of a subprogram with parameter transfer
A subprogram with parameter transfer is defined using the PROC keyword and a complete list
of all the parameters expected by the subprogram.
Incomplete parameter transfer
When the subprogram is called, not all the parameters defined in the subprogram interface
have to be transferred explicitly. If a parameter is omitted, the default value "0" is transferred for
it.
So that the parameter sequence can be uniquely identified, however, the commas used as
parameter separators always have to be included. The last parameter is an exception. If it is
omitted from the call, the last comma can also be left out.
Example:
Subprogram:
Program code
PROC SUB_PROG (REAL X, REAL Y, REAL Z)
...
N100 RET
Main program:
Program code
PROC MAIN_PROG
...
494
Comment
; Variable definition
; Variable assignment
; Subprogram call with actual parameters: 5.5
and WIDTH
Comment
; Formal parameters: X, Y, and Z
Comment
Programming Manual, 12/2019, 6FC5398-2EP40-0BA0
NC programming