Switch; Switch...case - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Regarding

SWITCH...CASE

The
SWITCH...CASE
based on the evaluation of a single condition. The value of the
value (numeric constant or string literal). If a match is found, the statements associated with the
CASE
are executed. All other
CASE
statements (if any) are executed. The
SWITCH (x)
{
}
This is programmatically the same programmatically as:
If (x = 1)
{
}
else if (x = 2)
{
}
else
Regarding
NetLinx Programming Language Reference Guide
statements:
SELECT...ACTIVE
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
assigned to a given condition.
statement provides a programming structure for selective execution of code blocks
statements are ignored. If no match is found, the
CASE

SWITCH

CASE 1 :
//do stuff when x = 1
{
}
CASE 2 :
//do stuff when x = 2
{
}
default :
// do stuff when x is not 1 or 2
{
}
//do stuff when x = 1
//do stuff when x = 2
// do stuff when x is not 1 or 2
statements:
SWITCH...CASE
Only the statements associated with the first case that matches the value of the expression are
executed.
If no
matches the
CASE
SWITCH
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
statement applies to the
BREAK
Unlike the C language, cases do not fall through to the next case if a break is not used.
s are recommended between cases. For example:
BREAK
statements are required only if multiple statements are
ACTIVE
SWITCH
expression is evaluated only once. An example is:
expression, the statements under the default case (if
. It takes execution to the end of the
SWITCH
Language Elements
expression is tested against each
case
DEFAULT
SWITCH
.
33

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents