NetLinx Programming Overview
15
NetLinx Programming Language Reference Guide
DEFINE_TYPE
STRUCTURE EMP
{
INTEGER EMP_NUM
CHAR NI_NUM[9]
CHAR F_NAME[16]
CHAR L_NAME[16]
FLOAT CONT_PENSION
}
Then, within the DEFINE_VARIABLE section, you create an instance of the structure and an array of
the structure as follows:
DEFINE_VARIABLE
EMP JOHN_DOE
EMP AMX_EMP[1000]
Within the program, we use the information stored within the structure and assign information to the
structure in the following manner:
JOHN_DOE.EMP_NUM = 101
JOHN_DOE.NI_NUM = ’155426367’
JOHN_DOE.F_NAME = ’JOHN’
JOHN_DOE.L_NAME = ’DOE’
JOHN_DOE.CONT_PENSION = 0.01
EMP_INDEX = JOHNDOE.EMP_NUM (* EMP_INDEX = 101 *)
AMX_EMP[101] = JOHNDOE
(* AMX_EMP[101] = {101, '155426367', 'JOHN', 'DOE',
0.01}*)
AMX_EMP[60].EMP_NUM = 60
AMX_EMP[60].F_NAME = 'BOB'
Other uses for arrays of structures include channel listings, speed-dial lists, and user password lists.
Data sets
NetLinx predefines several structures designed to work with NetLinx device numbers, channels, and
levels. Data sets allow you to group and combine certain elements of NetLinx devices. There are three
data set structures supported by NetLinx:
 DEV (Device Sets)
 DEVCHAN (Device-Channel Sets)
 DEVLEV (Device-Level Sets)
You have already seen the structure
DEV structure in the DEFINE_DEVICE section. If we were to define
the structure
DEV in the DEFINE_TYPE section, it would look like this:
STRUCTURE DEV
{
INTEGER DEVICE
INTEGER PORT
INTEGER SYSTEM
}