beautypg.com

7 compound statements – Teledyne LeCroy LeCroy Analyzers File Based Decoding Manual User Manual

Page 31

background image

File-based Decoding User Manual

Chapter 7: Statements

LeCroy Corporation

25

because the if statement evaluates to false. This causes the first return statement to
be skipped. The function continues executing with the else statement, thereby returning
the value of b to be used as an argument to Trace.

7.7 Compound Statements

A compound statement, or statement block, is a group of one or more statements that
is treated as a single statement. A compound statement is always enclosed in curly
braces ( {} ). Each statement within the curly braces is followed by a semicolon;
however, a semicolon is not used following the closing curly brace.

The syntax for a compound statement is

{

;

;

...

;

}

An example of a compound statement is

{

x = 2;

x + 3;

}

It's also possible to nest compound statements, like so:

{

x = 2;

{

y = 3;

}

x + 3;

}

Compound statements can be used anywhere that any other kind of statement can be
used.

if (3 && 3)

{

result = "True!";

Trace(result);

}

Compound statements are required for function declarations and are commonly used in
if

, if-else, while, and for statements.