Subroutines, Macros
2.4 Call subroutines (L or EXTERN)
Job planning
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
2-11
Example: Subroutine call with parameter transfer
N10 DEF REAL LENGTH,WIDTH,DEPTH
N20…
N30 LENGTH=15.3 WIDTH=20.2 DEPTH=5
N40 BORDER(LENGTH,WIDTH,DEPTH)
or
N40 BORDER(15.3,20.2,5)
1%25'(5
1%25'(5/(1*7+:,'7+'(37+
1/(1*7+ :,'7+ '(37+
RU
0DLQSURJUDP
Example: subroutine
PROC SUB1 (INT VAR1, DOUBLE VAR2)
IF $P_SUBPAR[1]==TRUE
;Parameter VAR1 was programmed in the subroutine call
ELSE
;Parameter VAR1 was not programmed in the subroutine call
;and initialized by the system with the default value 0
ENDIF
IF $P_SUBPAR[2]==TRUE
;Parameter VAR2 was programmed in the subroutine call
ELSE
;Parameter VAR2 was not programmed in the subroutine call
;programmed and initialized by the system with the default value 0.0
ENDIF
;Parameter 3 is not defined
IF $P_SUBPAR[3]==TRUE -> Alarm 17020
M17