Calling Routines

The syntax of calling a function and a shape have significant differences but the way parameters a handled is the same. So the details of the calls will be covered separately first then the common syntax for the parameters will be covered.

Functions

A function call consists of a function name and the list of actual parameters. The parentheses must be included even if there are no actual parameters.

functcall ::= functname ( [ parmlist ] )

A function call can occur wherever a term in an expression may occur. The function will be called and the return value will be used as if it had been where the call was written. So :-

res := 10 + Sin(30) * 2;

Would be the same as :-

res := 10 + 0.5 * 2;

Shapes

A shape invocation is always a statement on its own. See the Drawing Statements chapter.

Parameters

The actual parameter list takes the following form :-

parmlist ::= parm [[ , parm ]]

parm ::= expression | name -> expression

There are two ways of specifying a parameter: call by position and call but name.

With call by position the parameters are treated as if they are in the order in which they are declared in the routine's formal parameter list. In call by name the name of the parameter in the formal parameter list is used, followed by the -> delimiter, this is the hyphen, '-', followed, without spaces, by '>' ( it looks better in Courier font ).

It is possible to mix the two modes in a singles call - the position counting will follow the previous parameter whether that was positional or named. This mixing tends to be used if there are a few obligatory parameters at the start, then a lot of optional parameters where you only want a few.

If there was a function defined as follows :-

Function Number MyFunct(Number parm1, Number parm2, Number parm3 = 80, Number parm4 = 90)

It could be called with :-

res := MyFunct(4, 23, parm4 -> 50);