Subroutines, Macros
2.3 Subroutines with parameter transfer (PROC, VAR)
Job planning
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
2-7
Second method of parameter transfer:
• Values are only transferred (call-by-value)
If the parameters transferred are changed as the subroutine runs this does not have any
effect on the main program. The parameters remain unchanged in it (see Fig.).
1HZYDOXHVYDOLG
1HZYDOXHV
YDOLG
1HZYDOXH
DVVLJQPHQW
/(1*7+
:,'7+
6XESURJUDP
0DLQSURJUDP
9DOXH
DVVLJQPHQW
/(1*7+
:,'7+
/(1*7+:,'7+
/(1*7+:,'7+
• Parameter transfer with data exchange (call-by-reference)
Any change to the parameters in the subroutine also causes the parameter to change in the
main program (see Fig.).
Example: variable array lengths
%_N_DRILLING_PLATE_MPF Main program
DEF REAL TABLE[100,2] ;Define position table
EXTERN DRILLING_PATTERN (VAR REAL[,2],INT)
TABLE[0,0]=-17.5 ;Define positions
…
TABLE[99.1]=45
DRILLING_PATTERN(TABLE,100) ;Subroutine call
M30