
Language Elements
45
NetLinx Programming Language Reference Guide
Declare a
DEVLEV
array whose maximum length is determined by the number of elements in
the initialization array on the right-hand side.
DEVLEV DLName[ ] = {{Dev1,Level1}, {Dev2,Level2}, ...}
Use
MAXLEN
to specify the maximum length of the array.
DEVLEV DLName[MAXLEN] = {{Dev1,Level1}, {Dev2,Level2}, ...}
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
LENGTH_ARRAY
. The maximum length
available for a
DEVLEV
array can be determined by calling
MAX_LENGTH_ARRAY
.
The individual elements of a level array can be referenced by their defined names (
Dev1
,
Level1
,
Dev2
,
Level2
, etc.) or alternatively, by using array notation with the device-level array name. For
example, the 3rd element in the device-level array,
MyDLSet
, would be referenced by
MyDLSet[3]
.
Furthermore, since a
DEVLEV
array is an array of
DEVLEV
structures,
DEVLEV
members can be
referenced using the dot operator notation such as
MyDLSet[3].Device
or
MyDLSet[1].Level
.
The index of the last member of the array for which an event notification was received can be determined
by calling
GET_LAST(MyDLSet)
. This is useful for determining which device and level in an array is
referenced to in a particular notification message.
Variables
NetLinx provides support for several different types of variables distinguished by attributes, such as:
Scope
Constancy
Persistence
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:
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.
Scope differentiates the two basic classes of NetLinx variables:
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
DEFINE_VARIABLE
section; its scope extends
throughout the module in which it is declared.
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
declarations only. For example, both formats shown below are legal in the NetLinx
language:
Содержание NETLINX PROGRAMMING LANGUAGE
Страница 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Страница 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Страница 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Страница 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Страница 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Страница 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Страница 114: ...Mainline 98 NetLinx Programming Language Reference Guide FIG 1 Message and Mainline Processing in the NetLinx System...
Страница 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Страница 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Страница 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Страница 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...