Compound statements – Teledyne LeCroy Merlins Wand - Users Manual User Manual

Page 289

Advertising
background image

273

CATC M

ERLIN

S

W

AND

2.00

C

HAPTER

D

User’s Manual

CATC Scripting Language

...
HiThere()
{

a = "Hi there";
b = "Goodbye";
if ( 3 != 3 ) return a;
else return b;

}

will output

Goodbye

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

.

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;
{

Advertising