Crestron
SIMPL+
Software
variables are also available with the INTEGER and STRING datatype. Integers are
16 bit quantities. For the 2-series control system, 32 bit quantities are supported with
the LONG_INTEGER datatype. Both INTEGER and LONG_INTEGER are treated
as unsigned values. Signed versions for both of these datatypes are available by
using the SIGNED_INTEGER and SIGNED_LONG_INTEGER datatypes. The
following example illustrates how each of these datatypes can be used within a
program module:
INTEGER intA, intB, intC;
STRING stringA[10], stringB[20];
LONG_INTEGER longintA, longIntB;
SIGNED_INTEGER sintA, sintB;
SIGNED_LONG_INTEGER slongIntA;
It is important to realize that all variables declared in this manner are non-volatile.
That is, they remember their values when the control system reinitializes or even if
the power is shut off and then turned back on. Since input/output variables are
attached directly to signals defined in the SIMPL program, they do not have this
property unless the signals they are connected to are explicitly made non-volatile
through the use of special symbols.
Structures
Sometimes sets of data are needed rather than individual pieces. Variables store a
piece of data, but are not related to other variables in any way. Structures are used to
group individual pieces of data together to form a related set. Before structures can
be used, a structure definition must be defined. Defining a structure is really defining
a custom datatype (such as STRINGs and INTEGERs). Once this new type (the
STRUCTURE) is defined, variables of that type can be declared. The following
example illustrates how a structure can be defined and used within a program
module:
STRUCTURE PhoneBookEntry
{
STRING name[100];
STRING address[100];
STRING phone_number[25];
INTEGER age;
}
PhoneBookEntry entry;
PhoneBookEntry entries[50];
To access a variable within a structure, the structure’s declared variable name is
used, followed by a period (also known as the ‘dot’ or ‘dot operator’), followed by
the structure member variable name. For example:
entry.name = “David”;
entries[1].age = 32;
Programming Guide – DOC. 5789A
SIMPL+
•
9