NetLinx Modules
197
NetLinx Programming Language Reference Guide
NetLinx Modules
The ability to reuse code is a desirable goal in software development; however, code reuse takes careful
planning and organization. As discussed earlier, NetLinx provides tools such as functions and modules
to promote reusability. Modules are NetLinx sub-programs designed to be "plugged into" a main
program.
Defining a module
The
MODULE_NAME
entry on the first line of the file defines the module. The syntax is:
MODULE_NAME = '<module name>' [(<parameter list>)]
The
MODULE_NAME
entry identifies the file as containing a NetLinx module, as opposed to a standard
NetLinx source code file. The module name is any valid string literal not to exceed 64 characters. A file
can contain only one module and the file name must be the same as the module name with the addition of
the ".AXS" extension.
Module parameters behave exactly like subroutine parameters; the parameter list is optional. The value
for each parameter is set either by the main program or another module. If the value of a parameter is
changed, both the main program and module see the change.
The example below defines a module named
ModuleExample
. Aside from the
MODULE_NAME
entry,
the code looks like any standard NetLinx source code file.
All parameters to a module must be one of the instrinsic types:
CHAR
,
INTEGER
,
SINTEGER
,
LONG
,
SLONG
,
FLOAT
,
DOUBLE
,
DEV
,
DEVCHAN
or
DEVLEV
. Also, any of the above array types can be used.
MODULE_NAME='ModuleExample'(DEV dvDECK, DEVCHAN dcTRANPORTS[], INTEGER nFIRST)
(*{{PS_SOURCE_INFO(PROGRAM STATS) *)
(***********************************************************)
(* ORPHAN_FILE_PLATFORM: 1 *)
(***********************************************************)
(*}}PS_SOURCE_INFO *)
(***********************************************************)
(* DEVICE NUMBER DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_DEVICE
(***********************************************************)
(* CONSTANT DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_CONSTANT
NO_BUTTON = 0
NO_FUNCTION = 256
PLAY = 1
STOP = 2
Constants and expressions cannot be used as arguments in the parameter list.
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...