Using Subroutines; Defining A Subroutine; Calling Subroutines - AMX AXCESS CONTROL SYSTEM PROGRAM Instruction Manual

Programming language
Table of Contents

Advertisement

Using Subroutines

In larger programs, you may want to break the program into smaller, more manageable parts called
subroutines. A subroutine is a section of code that stands alone and can be called from anywhere
else in the program. The most common usage of subroutines is to execute the same group of
instructions from different places in the program. Using a subroutine allows you to avoid having to
retype those instructions over and over in the program. Instead, you can just call the subroutine.

Defining a Subroutine

In Axcess, subroutines are created using the DEFINE_CALL statement. The subroutine name
follows the DEFINE_CALL keyword, enclosed in single quotes. There are certain restrictions for
subroutine names:
!
!
!
Subroutines must be defined before they can be used. For this reason, DEFINE_CALLS are usually
found right before the DEFINE_START section of the program. For example:
DEFINE_VARIABLE
LIGHT_PRESET
DEFINE_CALL 'PRESET LIGHTS' (CARD,PRESET)
{
PULSE[CARD,PRESET]
LIGHT_PRESET = PRESET
}
DEFINE_START
CALL 'PRESET LIGHTS' (LIGHTS,LIGHT_FULL)
DEFINE_PROGRAM
PUSH[TP,7]
CALL 'PRESET LIGHTS' (LIGHTS,LIGHT_OFF)
[TP,7] = (LIGHT_PRESET = LIGHT_OFF)
Spaces in the subroutine name are allowed, since it is a string literal. The subroutine's code must be
enclosed in braces. Regardless of how long the subroutine is, it must be in this format.

Calling subroutines

To tell Axcess to execute a subroutine, use the CALL keyword and the name of the subroutine in
single quotes. For example, to execute the previous subroutine, type the following where you want
the CALL to occur.
CALL 'LIGHTS OFF'
When Axcess executes the CALL, program execution jumps to the first line inside the braces of the
DEFINE_CALL. The subroutine is executed only once, and then Axcess returns to the statement
directly following the CALL statement.
Axcess Programming Language
They cannot be previously defined contents or variables.
They cannot be names that have already been assigned to BUFFERs or WAITs.
They are case-sensitive; Test and TEST are not the same.
(* CURRENT LIGHTING PRESET *)
(* LIGHTS OFF *)
Using Subroutines
89

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Axcess

Table of Contents