beautypg.com

3 if-else statements, 4 while statements, 3 if-else statements 7.4 while statements – Teledyne LeCroy Protocol Analyzers File-Based Decoding User Manual User Manual

Page 28

background image

Chapter 7: Statements

File-based Decoding User Manual

22

LeCroy Corporation

7.3 if-else Statements

The form for an if-else statement is

if <expression> <statement1>
else <statement2>

The following code

str = "";
if ( 3 - 3 || 2 - 2 ) str = FormatEx ( "%s", "Yes" );
else str = FormatEx ( "%s", "No" );

causes “No” to be printed, because 3 - 3 || 2 - 2 evaluates to False (neither
3 - 3 nor 2 - 2 is nonzero).

7.4 while Statements

A while statement is written as

while <expression> <statement>

An example of this is

str = "";
x = 2;
while ( x < 5 )
{
str += FormatEx ( "%d", x );

x = x + 1;

}

The result of this would be

str == "234"