This section describes how to define and invoke a function procedure. Assigning a value to the procedure name in the function procedure sets the return value.
A "Function" statement defines a function procedure with the following syntax:
Function function_name(argument_list)
statement_block
function_name = return_value
End Function
where "function_name" is the name of the function, "argument_list" a list of variables used
to pass data into and/or out of the function, and "return_value" is the value to be returned explicitly
to the invoking statements.
Of course, "argument_list" is optional.
Assigning the return value to the function name is also optional. If not given, a default value
will be returned to the invoking statements. But this is not recommended.
Invoking a function procedure is simple, no need of any special statements. Just use the function
name with an argument list in any expression:
... function_name(argument_list) ...
This will cause the system to:
Stop evaluating the expression.
Map data or variables based on the argument list.
Execute the entire statement block defined inside the function.
Take the value returned in the function name.
Continue to evaluate the expression.
If you want terminate a function procedure early, you can use the "Exit" statement: