Variables; Scope; Local Variables - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

In either case, the number of elements in the initialization array determines the effective length of the
array. That value can be determined at run-time by calling
available for a
The individual elements of a level array can be referenced by their defined names (
,
Dev2
Level2
example, the 3rd element in the device-level array,
Furthermore, since a
referenced using the dot operator notation such as
The index of the last member of the array for which an event notification was received can be determined
by calling
referenced to in a particular notification message.

Variables

NetLinx provides support for several different types of variables distinguished by attributes, such as:

Scope

Scope is a term used in reference to program variables that describe where in the program they can be
accessed. There are two types:
Scope differentiates the two basic classes of NetLinx variables:

Local variables

Local variables are restricted in scope to the statement block in which they are declared. A statement
block is one or more NetLinx statements enclosed in a pair of braces, like the blocks following
subroutines, functions, conditionals, loops, waits, and so on. Local variables must be declared
immediately after the opening brace of a block but before the first executable statement. To provide
compatibility with the Axcess language, local variables may be declared right before the opening brace
for
DEFINE_CALL
language:
NetLinx Programming Language Reference Guide
Declare a
array whose maximum length is determined by the number of elements in
DEVLEV
the initialization array on the right-hand side.
DEVLEV DLName[ ]
Use
to specify the maximum length of the array.
MAXLEN
DEVLEV DLName[MAXLEN] = {{Dev1,Level1}, {Dev2,Level2}, ...}
array can be determined by calling
DEVLEV
, etc.) or alternatively, by using array notation with the device-level array name. For
array is an array of
DEVLEV
. This is useful for determining which device and level in an array is
GET_LAST(MyDLSet)
Scope
Constancy
Persistence
Local scope: a variable can only be accessed in the subroutine or method that it is declared.
Global scope: a variable can be accessed anywhere in the program.
Local variable: a variable declared within a subroutine or function whose scope is limited to
that subroutine or function.
Global variable: a variable declared in the
throughout the module in which it is declared.
declarations only. For example, both formats shown below are legal in the NetLinx
= {{Dev1,Level1}, {Dev2,Level2}, ...}
LENGTH_ARRAY
MAX_LENGTH_ARRAY
, would be referenced by
MyDLSet
structures,
DEVLEV
DEVLEV
MyDLSet[3].Device
DEFINE_VARIABLE
Language Elements
. The maximum length
.
,
,
Dev1
Level1
.
MyDLSet[3]
members can be
or
.
MyDLSet[1].Level
section; its scope extends
45

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents