Syntax
exit fn [= expr]
Description
Useful, for example, when code needs to break out of a loop (e.g. while, for) and quit the function immediately; exit fn is safer than using goto.
Note: if the code only needs to exit the current loop or skip the current loop iteration, the break and continue statements are better-suited.
Operation
Immediately exits the currently executing function (n.b. see Important Usage Note below) via the function's end fn statement, and returns any value specified therein.
If the optional = expr is used, it overrides any value/expression specified in the function's end fn statement and returns expr instead.
Important Usage Note
An exit fn statement is valid only within a local fn function.
Examples
void local fn DoIt( string as CFStringRef )
if ( string == NULL ) then exit fn // exits the function without returning an expr
// ...
end fn
local fn MyFunction( value as long ) as long
if ( value > 100 ) then exit fn = 0 // exits the function, returning 0
// ...
end fn = value * 4
See also
local fn; end fn; goto; exit <label>; continue; break