Technical data

Compiler Directives
2-45
A function optionally returns a value with the %return directive. The returned
value can be any of the types defined in the Target Language Values table.
In this example, a function,
name, returns x, if x and y are equal, and returns
z, if x and y are not equal.
%function name(x,y,z) void
%if x == y
%return x
%else
%return z
%endif
%endfunction
Function calls can appear in any context where variables are allowed.
All
%with statements that are in effect when a function is called are available
to the function. Calls to other functions do not include the local scope of the
function, but do include any
%with statements appearing within the function.
Assignments to variables within a function always create new, local variables
and can not change the value of global variables unless you use the
:: scope
resolution operator.
By default, a function returns a value and does not produce any output. You
can override this behavior by specifying the
Output and void modifiers on the
function declaration line, as in:
%function foo() Output
%endfunction
In this case, the function continues to produce output to the currently open file,
if any, and is not required to return a value. You can use the
void modifier to
indicate that the function does not return a value, and should not produce any
output, as in:
%function foo() void
%endfunction