Teledyne-lecroy CATC Scripting Language Reference Manual Manual do Utilizador Página 11

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 57
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 10
C
HAPTER
3
Expressions
CATC Scripting Language
7
x = 10
Value_of_x = select {
x < 5 : "Less than 5";
x >= 5 : "Greater than or equal to 5";
};
The above expression will evaluate to Greater than or equal to 5” because the first
true expression is x >= 5. Note that a semicolon is required at the end of a
select expression because it is not a compound statement and can be used in an
expression context.
There is also a keyword default, which in effect always evaluates to true. An
example of its use is
Astring = select {
A == 1 : "one";
A == 2 : "two";
A == 3: "three";
A > 3 : "overflow";
default : null;
};
If none of the first four expressions evaluates to true, then default will be eval-
uated, returning a value of null for the entire expression.
select expressions can also be used to conditionally execute statements, similar
to C switch statements:
select {
A == 1 : DoSomething();
A == 2 : DoSomethingElse();
default: DoNothing();
};
In this case the appropriate function is called depending on the value of A, but the
evaluated result of the select expression is ignored.
Vista de página 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 ... 56 57

Comentários a estes Manuais

Sem comentários