Functions

Syntax

You can include function calls to internal and external routines in an expression anywhere that a data term (such as a string) would be valid, using the notation:

 ──function─name(─┬──────────────────┬─)────

                    │ ┌──────,───────┐ │

                    │               │ │

                    └─┴┬────────────┬┴─┘
                       └─expression─┘

function-name is a literal string or a single symbol, that is taken to be a constant.

There can be up to a maximum of 20 expressions, separated by commas, between the parentheses. These expressions are called the arguments to the function. Each argument expression may include further function calls.

The ( must be adjacent to the name of the function, with no blank in between, or the construct is not recognized as a function call. (A blank operator is assumed at this point instead.)

The arguments are evaluated in turn from left to right and they are all then passed to the function. This then executes some operation (usually dependent on the argument strings passed, though arguments are not mandatory) and eventually returns a single character string. This string is then included in the original expression as though the entire function reference had been replaced by the name of a variable that contained that data.

For example, the function SUBSTR is built-in to the language processor and could be used as:

N1='abcdefghijk'
Z1='Part of N1 is: 'Substr(N1,2,7)
/* would set Z1 to 'Part of N1 is: bcdefgh' */

A function call without any arguments must always include the parentheses to be recognized as a function call.

date()  /* returns the date in the default format dd mon yyyy */

Calls to Functions and Subroutines

The mechanism for calling functions and subroutines is the same. The only difference is that functions must return data, whereas subroutines need not. The following types of routines can be called as functions: