User Guide

Table Of Contents
Program Methodology—Converting a Sequence of Operation into
Program Code
Siemens Building Technologies, Inc. 1-99
Designing Programs Using a Modular Structure
Modular programming is a style of programming that logically
organizes code into common functions. This style of programming
can be applied to a single program, or to multiple programs running
on the network or in one field panel.
Objectives of Modular Programming
The objectives of modular programming are to reduce program code
and standardize program code.
Reducing Program Code
If a section of code is used many times during one pass of the
program, that code can be defined as a subroutine (also called a
module). When that routine is needed, control is transferred to that
part of the program.
Standardizing Program Code
Subroutines help set programming standards that define where
functionality is placed in the program. If you use an established block
of code and do not change the line numbers, then that subroutine
will always be placed in the same location in the program.
APOGEE PPCL User’s Manual
1-100 Siemens Building Technologies, Inc.
Benefits of Using Subroutines
By defining functions, procedures, and formulas in subroutines,
programs become faster to create, easier to write, and require less
time to test. A subroutine used for one device can also be adapted
for other devices.
For example, if a specific operation is performed five different times
during one pass of the program, you have two programming options.
1. The first option is to duplicate the code in five different places in
the program.
This option adds five times as much program code.
When making a change to one segment, you must
remember to change all occurrences of that code.
2. The second option is to use a subroutine. Every time the
operation is needed, program control is transferred to the
subroutine.
This option reduces the amount of mainline program code.
When making a change, there is only one section of code to
change.
When to Use a Subroutine
Before creating a subroutine, determine if the subroutine contains
enough lines and is accessed enough times through one pass of the
program to be of any benefit. There are times that straight-line
program code will be the optimal solution.
A single line of program code placed in a subroutine will never be
executed enough times to be of any benefit. In this case, you
would create more program code for a subroutine than you would
by using straight-line program code
Conversely, a subroutine containing four lines of program code
becomes beneficial when it is called more than once.