Constancy; Persistence - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Language Elements
Modules are reusable NetLinx sub-programs that can be inserted into the main
program. The main program is also a module. Refer to the NetLinx Modules section
on page 143 for information on program modules.
If a local variable shares the same name as a global variable, the local variable always takes precedence.
The general form of a global variable definition is:
[NON_VOLATILE | VOLATILE | PERSISTENT] [CONSTANT] [<type>] name [= <value>]

Constancy

Any variable may also be assigned the attribute
(cannot change at run-time). The variable must be initialized as part of its declaration if this keyword is
used.

Persistence

The persistence of a variable is controlled through the
keywords.
If the data type is omitted from the variable definition, the following defaults are assumed:
You can define a variable to be persistent using the
DEFINE_VARIABLE
PERSISTENT CHAR cMyString[100]
All persistent variables are automatically non-volatile, and it's not legal to define a variable as
VOLATILE
Any time after a NetLinx program that has a persistent variable declared subsequent downloads of new
NetLinx programs that contain the same persistent variable will automatically be set to contain the same
value as it previously did. The default behavior for non-persistent variables is they are set to zero after a
NetLinx program downloads. Persistence overrides this behavior by setting the variable in the newly
downloaded program to be the same as it was before the download.
Typically, persistent variables are used for saving preset information. Suppose you have a system that
contains several Positrack camera positioning systems and that the user interface to the system allows the
user to set the position of any of the cameras and record that position for recalling later. The position
presets are stored in a non-volatile array variable so they are maintained during a power cycle. Without
persistent variables, an update to the NetLinx program would zero out all of the presets that the user had
48
Non-volatile variables: A variable declared with the
non-volatile memory. It will retain its value in the event of a system power-down, but is reset
to zero if the program is reloaded. Unless specified otherwise, all variables are stored in non-
volatile memory.
Volatile variables: A variable declared with the
memory and resets to zero after either a power-down or reload. Volatile memory is generally
faster and more plentiful than non-volatile memory. For this reason, you should use the
keyword when declaring large data arrays where persistence of the data is not a
VOLATILE
requirement.
Persistent variables: If a variable is declared with the
to zero the first time the program is loaded but will retain its value after either power-down or
reload.
Single variables are
INTEGER
Arrays are
type.
CHAR
and
.
PERSISTENT
. This declares a variable to be immutable
CONSTANT
NON_VOLATILE
NON_VOLATILE
VOLATILE
PERSISTENT
type.
storage modifier as show below:
PERSISTENT
NetLinx Programming Language Reference Guide
,
and
VOLATILE
PERSISTENT
keyword is stored in
keyword is stored in volatile
keyword, it is initialized

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents