7 compound statements – Teledyne LeCroy Protocol Analyzers File-Based Decoding User Manual User Manual
Page 32

Chapter 7: Statements
File-based Decoding User Manual
26
LeCroy Corporation
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
{
<first_statement>;
<second_statement>;
...
<last_statement>;
}
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.
str = "";
if (3 && 3)
{
result = "True!";
str = FormatEx ( "%s", result );
}
Compound statements are required for function declarations and are commonly used in
if, if-else, while, and for statements.