method [` Switch ...] [[ [Keyword =] {Array, Expression}], ...]
A method invocation passes control to the called method. Control will normally return to the calling method. An exception handler in the called method may either return to the calling method or raise an exception and begin unwinding the call stack. The call stack will be unwound until the exception is caught by an exception handler or exits the program entirely.
A call is coded starting with the Method name followed by an optional argument list. Functions can also be called using the same syntax, but usually they are invoked within an arithmetic expression. A foreign procedure with a mixed case name can be called by quoting its name. Otherwise the Method or Function name is case insensitive.
PUT.ENVIRONMENT Name, Value; Call the Put.Environment Method. IS.PRIME N, Prime; Call the Function Is.Prime as a Method. "random_seed" Seed; Call a foreign procedure.
The argument list may start with one or more switch names denoted by a leading tick. The name of a switch is the name of an Entry parameter with a Bit type. Usually it is most convenient to code switches as the last parameters in a Method.
method FORM.PATH.SLASH pure :A Method signature with an optional switch change Path string :A required paramater entry Forward = 0 Bit :A Bit parameter can be called with a switch FORM.PATH.SLASH`Forward Path; Call with Forward set to one. FORM.PATH.SLASH Path; Call with Forward defaulting to zero.
After optional switches the remaining arguments are separated by commas. Arguments can be called using a keyword prefix with the parameter name followed by an equal sign and the argument value. Using keywords allows parameters to be listed in any order. Otherwize positional arguments are listed in the order corresponding to the parameters in the Method signature. The argument list may start with positional arguments followed by keyword arguments.
method COPY.FILE :Method signature for copying files entry From string, &Source path To string :Destination path COPY.FILE Here, There; Parameters in the order they are declared COPY.FILE From=Here, To=There; Call using parameter names COPY.FILE To=There, From=Here; Parameter names can be in any order.
A null positional argument is denoted by omitting any value. If the parameter declaration corresponding to a null has a default value, it will be used as the argument value. A compilation error is issued if the parameter declaration has no default value.
Type checking is performed between the listed arguments and the parameters declared in the called module. An argument will be implicitly cast if the corresponding parameter has a different type. The argument to an Entry parameter may be any valid expression cast to the parameter type. An argument to a Change parameter must have the same type as the parameter.
An Exit parameter can be declared as a reference or wizard pointer. An address is returned and stored in the argument which must be a pointer. The argument is coded as an at sign ('@') followed bythe name of the pointer. If the parameter is declared as a wizard then the argument must also be a wizard pointer.
Arrays may also be passed as arguments by using just the array name as the argument. Arrays are always passed by reference and array data is never copied on a module invokation. The array element type and the size of each dimension must match between the argument and parameter declaration. However the lower bounds can be different constants.
method PRINT.ARRAY :Signature of the method to be called entry Array[9] single &Array with a default lower bound of zero method CALLER :Calling method local Data[1 to 10] :Array with a lower bound of one PRINT.ARRAY Data; Call works as long as the size matches.
Array parameters can include a length parameter so that procedures can process arrays of varying sizes. The upper bound of an array parameter is designated by a star ('*'). If a name is coded after the star the bound with be stored in a Word variable created with that name. Also see Variable Length Array on the Local Variable Declaration page.
method PROCESS.ARRAY entry A[*Max] single :The local, Max, will be set to the upper bound of A change B[1 to *] string :The compiler can upper bound of B to scan it.