User Guide

Table Of Contents
Command Syntax
Siemens Building Technologies, Inc. 3-51
When using multi-level subroutines, the rules that govern $ARGn
variables and point name declarations for GOSUB commands
change as follows:
$ARGn variables used in multi-level subroutines cannot be
shared between subroutine levels. That is, you cannot assign the
value of PT1 to $ARG1 in the call to level one and then assign
the value of PT2 to $ARG1 in the call to level two.
When defining a new level in a multi-level subroutine, list the
previously-defined $ARGn variables in sequential order to
preserve their values.
Any new points declared in that level must be placed after the
$ARGn variables. For example, in the third level of a multi-level
subroutine, $ARG1 and $ARG2 would be redefined before the
defining the new value of PT3.
If a previously-defined $ARGn variable is not redefined in the call
to a new level, any values introduced in the new level replace the
values in $ARGn.
Subroutine Examples
To explain the concept of subroutine program control, two examples
of program code are provided in this section:
Program flow sequence
Multiple level subroutines
Program Flow Sequence
This example demonstrates how a number of PPCL commands are
used in subroutines. Refer to Figure 3-1 as you follow the program
flow sequence.
The variables PT1 and PT2 demonstrate the passing of values
between subroutines.
The $ARG local variable demonstrates how values are passed
between subroutines.
The GOTO command, which is used to bypass subroutines, is
also shown in this example.
APOGEE PPCL User’s Manual
3-52 Siemens Building Technologies, Inc.
The program flow through one complete pass is as follows:
1. At line 130, the GOSUB command transfers control to line 1010.
2. At line 1010, the program assigns a value of 10 to PT1 and the
value of 20 to PT2. Line 1030 branches back to the line after the
GOSUB command (at line 130). After the program returns to the
main line code, the values of the two points become:
PT1 = 10
PT2 = 20
3. The program continues to sequentially evaluate program lines
until it encounters the GOSUB command at line 300. The
program branches to line 2010. This command also defines two
values that are passed (PT1 and PT2).
4. At line 2010, a $ARGn point is assigned a value. When the
program encounters a $ARGn point, it checks the calling
GOSUB command for point names. The GOSUB command used
to call this subroutine contains two point names. When the
program encounters the first $ARGn variable at line 2010, it
takes the first point name defined in the GOSUB command
(PT1) and stores that value in $ARG1 (10). Line 2010 also adds
one (1) to the value of $ARG1.
5. When the program encounters the second $ARGn variable at
line 2020, it takes the second point name defined in the GOSUB
command (PT2) and stores that value in $ARG2 (20). Line 2020
also adds one (1) to the value of $ARG2.
Line 2030 returns control of the program to the line after the
GOSUB command (at line 300). At line 400, the program
executes the GOTO command to line 3000 that returns control
back to mainline code.
After one pass of the program, the values of the points after
being updated by the $ARGn variables, will be as follows:
PT1 = 11
PT2 = 21