Language Elements
33
NetLinx Programming Language Reference Guide
Regarding
SELECT...ACTIVE
statements:
Only the statements associated with the first condition evaluated to true are executed.
If no condition evaluates to true, no statements are executed.
Braces underneath individual
ACTIVE
statements are required only if multiple statements are
assigned to a given condition.
SWITCH…CASE
The
SWITCH…CASE
statement provides a programming structure for selective execution of code blocks
based on the evaluation of a single condition. The value of the
SWITCH
expression is tested against each
CASE
value (numeric constant or string literal). If a match is found, the statements associated with the
CASE
are executed. All other
CASE
statements are ignored. If no match is found, the
DEFAULT
case
statements (if any) are executed. The
SWITCH
expression is evaluated only once. An example is:
SWITCH (x)
{
CASE 1 : //do stuff when x = 1
{
}
CASE 2 : //do stuff when x = 2
{
}
default : // do stuff when x is not 1 or 2
{
}
}
This is programmatically the same programmatically as:
If (x = 1) //do stuff when x = 1
{
}
else if (x = 2) //do stuff when x = 2
{
}
else // do stuff when x is not 1 or 2
Regarding
SWITCH...CASE
statements:
Only the statements associated with the first case that matches the value of the expression are
executed.
If no
CASE
matches the
SWITCH
expression, the statements under the default case (if
available) are executed.
All cases must be unique.
Braces should be used to bracket the statements in a case. They are required only if variables
are declared within the case.
The
BREAK
statement applies to the
SWITCH
. It takes execution to the end of the
SWITCH
.
Unlike the C language, cases do not fall through to the next case if a break is not used.
BREAK
s are recommended between cases. For example:
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...