NetLinx Programming Overview
11
NetLinx Programming Language Reference Guide
NetLinx allows variables to be defined as constants in the
DEFINE_VARIABLE
section of the program
or module, and in the
LOCAL_VAR
section of a
DEFINE_CALL
or a
DEFINE_FUNCTION
. Assigning
constants is consistent with C++ programming conventions.
Variables
The role of the
DEFINE_VARIABLE
section is enhanced for NetLinx. The structure of a variable
definition is:
[NON_VOLATILE|VOLATILE][CONSTANT][<type>]<variable name> [= <value>]
NetLinx handles variables just like Axcess. NetLinx defaults non-array variables to the integer data types
and defaults array variables to character data type array. The variable must be explicitly declared if using
any other data type.
The
NON_VOLATILE
and
VOLATILE
keywords specify what happens to a variable when the program is
downloaded or after a system reset.
NON_VOLATILE
variables (the default) lose their values when the program is downloaded, but
retain their values when the system resets.
VOLATILE
variables lose their values when the system is loaded and after the system resets.
If you initialize a
VOLATILE
variable in the
DEFINE_VARIABLE
section, the variable initializes every
time the code is loaded or after a system reset. The variable initializes like it would in the
DEFINE_START
section. If you initialize a
NON_VOLATILE
variable within the
DEFINE_VARIABLE
section, the variable only initializes when the system is loaded, and it retains any changed values after
system resets.
Variables can now be defined as constant variables. Since the
DEFINE_CONSTANT
section does not
allow you to explicitly declare a constant's data type, using the
CONSTANT
keyword allows you to
explicitly declare the data type of a constant, and to define constant values for structures and arrays of
structures.
CONSTANT STR_TV CHAN_5 = {'KXAS', 5}
CONSTANT SINTEGER ABS_ZERO = -273
With Axcess, the
DEFINE_CALL
section allowed you to define local variables with the
LOCAL_VAR
keyword. NetLinx expands the scope of
LOCAL_VAR
beyond the
DEFINE_CALL
section of code. Local
variables now come in two flavors:
LOCAL_VAR
now defines a static (fixed) local variable (the next time a
DEFINE_CALL
is
called, the last value of the
LOCAL_VAR
will be in memory unless the variable is initialized).
This is how Axcess handles variables defined with
LOCAL_VAR
. NetLinx does not limit
LOCAL_VAR
definitions strictly to the
DEFINE_CALL
section.
LOCAL_VAR
definitions can
appear within any statement block. This includes (but is not limited to)
DEFINE_FUNCTION
,
DEFINE_EVENT
,
WHILE
statements,
WAIT
statements, etc.
STACK_VAR
defines a non-static local variable.
STACK_VAR
defines local variables the same
way as
LOCAL_VAR
, and like
LOCAL_VAR
,
STACK_VAR
can appear in any statement block.
The difference is that the value stored in the variable is initialized to zero whenever the
statement block is called, and the value is destroyed when the statement block is finished. The
structure for
LOCAL_VAR
and
STACK_VAR
variables include:
LOCAL_VAR [NON_VOLATILE | VOLATILE] [CONSTANT] [<type>] name [= <value>]STACK_VAR
[<type>] name [= <value>]
Summary of Contents for NETLINX PROGRAMMING LANGUAGE
Page 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Page 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Page 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Page 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Page 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Page 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Page 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Page 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Page 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Page 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...