Teledyne LeCroy BPT - References Manual User Manual

Page 12

Advertising
background image

8

CATC S

CRIPTING

L

ANGUAGE

1.1

C

HAPTER

3

Reference Manual

Expressions

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.

Advertising