2
Subprograms, Macros 12.98
2.3 Sub
ro
rams with
arameter transfer
2
840D
NCU 571
840D
NCU 572
NCU 573
FM-NC 810D 840Di
ï›™
Siemens AG 2000. All rights reserved
2-96
SINUMERIK 840D/840Di/810D/FM-NC Programming Guide Advanced (PGA)
−
04.00 Edition
Example:
N10 DEF REAL LENGTH,WIDTH
N20 LENGTH=12 WIDTH=10
N30 BORDER (LENGTH,WIDTH)
The values assigned in N20 in the main program are
passed in N30 when the subprogram is called.
Parameters are passed in the sequence stated.
The parameter names do not have to be identical in
the main programs and subprogram.
LENGTH, WIDTH
Main program
Value assignment
LENGTH=12
WIDTH=10
Subprogram
New
value assignment
LENGTH=20
WIDTH=15
New values
apply
Old values
apply
Two ways of parameter transfer
Values are only passed (call-by-value)
If the parameters passed are changed as the
subprogram runs this does not have any effect on
the main program. The parameters remain
unchanged in it (see Fig.)
Parameter transfer with data exchange
(call-by-reference)
Any change to the parameters in the subprogram
also causes the parameter to change in the main
program (see Fig.).
LENGTH, WIDTH
LENGTH, WIDTH
Value assignment
LENGTH=12
WIDTH=10
Main progam
Subprogram
New
value assignment
LENGTH=20
WIDTH=15
New values
apply
New values
apply