202
Manual – IPOSplus®
16
switch...case...default
Compiler – Constructions
A continue statement is also possible. It causes the program to skip to the end of the
statement block and then to check the expression.
In this example, the incrementation of the IPOS
plus®
variable H0 stops as soon as the
value of the IPOS
plus®
variable H2 is greater than 10.
16.5 switch...case...default
16.5.1 Syntax
The switch statement makes it possible to create multiple program branches depending
on the value of an expression.
If Expression has the value 1, Statement 1 is performed, if Expression has the value 2,
Statement 2 is performed, etc. If none of the values following 'case' corresponds with
'Expression,' the default statement – if programmed – is executed (Statement n).
Statements 1, 2,..., n can also be function calls. For example, a jump distributor can be
set up.
Value 1, Value 2, Value n must be constants or constant expressions. No variables are
permitted here.
H2 = 0;
do
{
H2 = H2 +3;
if ( H2 > 20 )
break;
if ( H2 > 10 )
continue;
++H0;
} while ( 1 );
switch ( Expression )
{
case Wert 1:// statement 1
break;
case Wert 2:// statement 2
break;
.
.
default:// Statement n
}
INFORMATION
Statements 1, 2,..., n are normally sequences of statements which end with a break
statement. If the sequence of statements does not end with a break statement, all sub-
sequent case branches are performed until a break statement is encountered. The
value is then no longer compared with the expression.