Return statements, Return – Teledyne LeCroy Merlins Wand - Users Manual User Manual
Page 288

272
CATC M
ERLIN
’
S
W
AND
2.00
C
HAPTER
D
User’s Manual
CATC Scripting Language
return
Statements
Every function returns a value, which is usually designated in a return
statement. A return statement returns the value of an expression to the
calling environment. It uses the following form:
return <expression>
An example of a return statement and its calling environment is
Trace ( HiThere() );
...
HiThere()
{
return "Hi there";
}
The call to the primitive function Trace causes the function HiThere()
to be executed. HiThere() returns the string “Hi there” as its value. This
value is passed to the calling environment (Trace), resulting in this output:
Hi there
A return statement also causes a function to stop executing. Any
statements that come after the return statement are ignored, because
return
transfers control of the program back to the calling environment.
As a result,
Trace ( HiThere() );
...
HiThere()
{
a = "Hi there";
return a;
b = "Goodbye";
return b;
}
will output only
Hi there
because when return a; is encountered, execution of the function
terminates, and the second return statement (return b;) is never
processed. However,
Trace ( HiThere() );