Local Variables and Parameter Keywords
The Local Variables and Parameter keywords supported by Axcess are described below:
Local Variables and Parameter Keywords
CALL
To tell Axcess to execute a
subroutine, use the CALL
keyword and the name of the
subroutine in single quotes.
DEFINE_CALL
In Axcess, subroutines are
created using the
DEFINE_CALL statement.
LOCAL_VAR
This keyword is used inside a
DEFINE_CALL to declare
local variables.
Axcess Programming Language
For example, to execute the subroutine LIGHTS OFF, 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 state-
ment.
The subroutine name follows the DEFINE_CALL keyword, enclosed in single
quotes. There are certain restrictions for these subroutine names:
• They cannot be previously defined constants or variables.
• They cannot be names that have already been assigned to BUFFERS or
WAITs.
• They are case-sensitive. For example, Test and TEST are not the same.
Subroutines must be defined before they can be used. For this reason,
DEFINE_CALLS are typically placed right before the DEFINE_START section
of the program. Here is the format:
DEFINE_CALL 'subroutine name'
{
(* The subroutine goes here *)
}
Spaces in the subroutine name are allowed because it is a string literal. Notice
that the subroutine's code is enclosed in braces. No matter how long the sub-
routine is, it must be in this format.
A local variable is a variable which is declared inside a DEFINE_CALL and can
only be used inside that same DEFINE_CALL. Variables declared in the main
DEFINE_VARIABLE section are called global variables. The words local and
global refer to a variable's scope, which determines the parts of the program
that can access the variable. Global variables have global scope; that is, the
entire program has access to them. A local variable has local scope, and can
only be accessed inside the DEFINE_CALL in which it is declared.
A local variable can have the same name as a local variable in another subrou-
tine. A local variable can also have the same name as a global variable. If this
happens, the local variable takes precedence in its scope; the global variable is
hidden.
Local variables are best used in cases where a subroutine needs to use a vari-
able, but no other piece of code needs it. Such variables are usually temporary
flags, loop counters, and other variables a subroutine may need to do its work.
Local variables are also static, meaning that they retain their values between
calls to the subroutine.
Using Subroutines
93
Need help?
Do you have a question about the AXCESS CONTROL SYSTEM PROGRAM and is the answer not in the manual?