User Guide

Table Of Contents
Command Syntax
Siemens Building Technologies, Inc. 3-55
As the program branches from the second subroutine to the
third subroutine, $ARG1 and $ARG2 continue to represent
PT1 and PT2 respectively.
1000 C MAINLINE PROGRAM FOR LOGICAL FIRMWARE
1010 C
1020 C THIS PROGRAM TEACHES HOW GOSUBS AND
1030 C $ARG POINTS WORK IN MULTIPLE
1040 C LEVEL SUBROUTINES.
1050 C
1100 ...
1200 ...
1300 ...
1350 C THIS GOSUB CALLS THE FIRST SUBROUTINE
1360 C AND PASSES THE VALUE DEFINED IN PT1 TO
1370 C TO $ARG1.
1380 C
1500 GOSUB 2030 PT1
2000 C
2010 C SUBROUTINE #1
2020 C
2030 ...
2040 ...
2050 C IN ORDER TO PRESERVE THE VALUE LOCATED
2060 C IN $ARG1, YOU MUST DEFINE $ARG1 IN THE
2070 C SECOND SUBROUTINE'S CALLING GOSUB. THE
2080 C PROGRAM ALSO PASSES A SECOND POINT
2090 C VALUE NAMED PT2.
2100 C
2500 GOSUB 3030 $ARG1,PT2
2510 RETURN
3000 C
3010 C SUBROUTINE #2
3020 C
3030 ...
3040 ...
3050 C IN ORDER TO PRESERVE THE VALUES
3060 C LOCATED IN $ARG1 AND $ARG2, YOU MUST
3070 C DEFINE BOTH POINTS IN THE THIRD
3080 C SUBROUTINE'S CALLING GOSUB. THE
3090 C PROGRAM ALSO PASSES A THIRD POINT
APOGEE PPCL User’s Manual
3-56 Siemens Building Technologies, Inc.
3100 C VALUE CALLED PT3.
3200 GOSUB 4020 $ARG1,$ARG2,PT3
3210 RETURN
4000 C SUBROUTINE #3
4010 C
4020 ...
4030 ...
4040 RETURN
Figure 3-2. Multiple Level Subroutines.
Notes
A GOSUB command can only reference point names or local
variables.
A GOTO command can be used inside of a subroutine only if the
command does not transfer program control out of that
subroutine.
The last line of a subroutine must be a RETURN command.
Do not transfer control out of a subroutine without using a
RETURN command.
Do not use time-based commands such as LOOP, SAMPLE,
TOD, and WAIT inside a subroutine.
Do not use an IF/THEN/ELSE command with a GOSUB
command.
See also
GOTO, RETURN