Chapter 7: statements, Expression statements, If statements – Teledyne LeCroy Merlins Wand - CSL manual (CATC Scripting Language Manual) User Manual

Page 25: If-else statements, 7 statements, Hapter, Tatements

Advertising
background image

19

CATC Scripting Language for Bluetooth Analyzers

CATC

Manual Ver. 1.21

C

HAPTER

7: S

TATEMENTS

Statements are the building blocks of a program. A program is made up of list of
statements.

Seven kinds of statements are used in CSL: expression statements, if statements, if-
else statements, while statements, for statements, return statements, and compound
statements.

Expression Statements

An expression statement describes a value, variable, or function.

<expression

>;

Here are some examples of the different kinds of expression statements:

Value: x + 3;

Variable: x = 3;

Function: Trace ( x + 3 );

The variable expression statement is also called an assignment statement, because
it assigns a value to a variable.

if

Statements

An

if

statement follows the form

if <expression> <statement>

For example,

if (3 && 3) Trace("True!");

will cause the program to evaluate whether the expression

3 && 3

is nonzero, or

True. It is, so the expression evaluates to True and the

Trace

statement will be

executed. On the other hand, the expression

3 && 0

is not nonzero, so it would

evaluate to False, and the statement wouldn't be executed.

if-else

Statements

The form for an

if-else

statement is

if <expression> <statement1>

else <statement2>

The following code

if ( 3 - 3 || 2 - 2 ) Trace ( "Yes" );

else Trace ( "No" );

Advertising