Skip to content

Forward Declarations

Procedures and functions can be forward declared using the Register_Procedure and Register_Function statements respectively. Forward declaring allows you to reference the procedure or function in some other piece of code before it is formally declared. The compiler would generate an error if you tried to do this without a forward declaration.

Syntax

The syntax of the Register_Procedure and Register_Function statements is as follows:

Register_Procedure {procedure-name} [{type1} {param1} {type2} {param2}]
Register_Function {function-name} [{type1} {param1} {type2} {param2}] Returns {return-type}

In other words, the syntax for forward declaring a procedure or function is the same as the first line of a regular procedure or function declaration, except that the commands Register_Procedure and Register_Function are used instead. The type, number, and order of parameters in the forward declaration must match the real procedure or function declaration.

Examples

Examples of forward procedure and function declarations are:

Register_Procedure DoWriteCharacters String sMessage
Register_Function Powerof Integer iX Integer iY Returns Integer

The above examples allow you to reference the registered procedure or function inside the body of some other procedure or function, even though its formal declaration has not yet been made.