Elmomc SimplIQ Software Manual Manual de usuario Pagina 47

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 226
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 46
SimplIQ Software Manual 4BThe SimplIQ User Programming Language
MAN-SIMSW (Ver. 1.4)
5-18
5.7.7 Switch Selection
Syntax:
switch (expression)
case (case_expression1)
statement1
case (case_expression2)
statement2
otherwise
statement
end
The switch statement causes an unconditional jump to one of the statements that is the
“switch body,” or to the last statement, depending on the value of the controlling
expression, the values of the case labels and the presence or absence of an otherwise label.
The switch body is normally a compound statement (although this is not a syntactic
requirement). Usually, some of the statements in the switch body are labeled with case
labels or with the otherwise label. Labeled statements are not syntactic requirements either,
but the switch statement is meaningless without them. The otherwise label can appear only
once, and must appear after at least one case label. In contrast to the case label, the
otherwise label cannot be followed by an expression for evaluation.
The switch and case expressions may be any logical and/or numerical expression. The case
expression in the case label is compared for equality with the switch expression. If the
switch expression and the case expression are equal, then this case is selected and the
statements between the matching case expression and the next case or otherwise label are
executed. After execution of the statements, a break keyword may appear. It is not
necessary a case statement to finish with a break, because after executing the statements, an
unconditional jump to the end of the switch is performed automatically, and the next case
statement is not executed.
If a number of case expressions match the switch expression, then the first matching case is
selected.
Vista de pagina 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 225 226

Comentarios a estos manuales

Sin comentarios