beautypg.com

While statements, For statements, While statements for statements – Teledyne LeCroy Merlins Wand - CSL manual (CATC Scripting Language Manual) User Manual

Page 26

background image

20

CATC Scripting Language for Bluetooth Analyzers

CATC

Manual Ver. 1.21

will cause “No” to be printed, because

3 - 3 || 2 - 2

will evaluate to False

(neither

3 - 3

nor

2 - 2

is nonzero).

while

Statements

A

while

statement is written as

while <expression> <statement>

An example of this is

x = 2;

while ( x < 5 )

{

Trace ( x, ", " );

x = x + 1;

}

The result of this would be

2, 3, 4,

for

Statements

A

for

statement takes the form

for (<expression1>; <expression2>; <expression3>) <statement>

The first expression initializes, or sets, the starting value for x. It is executed one
time, before the loop begins. The second expression is a conditional expression. It
determines whether the loop will continue -- if it evaluates true, the function keeps
executing and proceeds to the statement; if it evaluates false, the loop ends. The
third expression is executed after every iteration of the statement.

The example

for ( x = 2; x < 5; x = x + 1 ) Trace ( x, "\n" );

would output

Figure 7-1: Execution of a

for

statement