Register_Function
See Also: Function, Get, Register_Procedure
Purpose
To allow a function or a property to be referred to in expressions in parts of the program that precede the point at which the function is defined.
Syntax
Register_Function {message} [{type} {param} …] Returns {type}
What It Does
Before any function can be referred to in an expression, the compiler must know the name and the number and types of parameters of the function. If you need to refer to a function in an expression before the point at which the function is defined, the Register_Function command allows you to predefine the function in order to do so.
-
{message} is the name of the function that is forward referenced. Since the point of
Register_Functionis to predefine functions, this command should never be used after the point at which the function actually is defined. -
The data {type} should be given before the name of each parameter passed to the function. Acceptable data types are
integer,number,date,real, andstring. -
The name of the {param} may be anything that describes the use of the value in the function. The name may not be a reserved word and must follow the typical symbol rules.
Every function must be defined as returning a value. The {type} given after the Returns keyword identifies the data type of the function. This is probably the most important piece of information to the system. With this data type, all uses of the function in expressions will return the proper data type and be converted to match the function's definition.
Example
Register_Function
DoTheJob Integer iType String sName Returns Integer
If the function has already been defined by the program (possibly in a package) and the parameters and types of the function do not match those given in Register_Function, a compile-time error, "Illegal redefinition of function/message", is returned.
The Register_Function command can also be used to register properties so they can be accessed in expressions before they are defined.
Example
Register_Function
piHitCount Returns Integer