class Func extends Object
Represents a user-defined or built-in function and provides an interface to call it, bind parameters to it, and retrieve information about it or its parameters.
For information about other objects which can be called like functions, see Function Objects.
The Closure
class extends Func
but does not define any new properties.
For each built-in function or function definition within the script, there is a corresponding read-only variable containing a Func object. This variable is directly used to call the function, but its value can also be read to retrieve the function itself, as a value. For example:
InspectFn StrLen InspectFn InspectFn InspectFn(fn) { ; Display information about the passed function. MsgBox fn.Name "() is " (fn.IsBuiltIn ? "built-in." : "user-defined.") }
"FuncObj" is used below as a placeholder for any Func object, as "Func" is the class itself.
In addition to the methods and property inherited from Object, Func objects have the following predefined methods and properties.
Calls the function.
FuncObj(Param1, Param2, ...)
FuncObj.Call(Param1, Param2, ...)
Parameters and return value are defined by the function.
The "Call" method is implied when calling a value, so need not be explicitly specified.
Binds parameters to the function.
BoundFunc := FuncObj.Bind(Param1, Param2, ...)
Any number of parameters.
Type: Object
This method returns a BoundFunc object.
Determines whether a parameter is ByRef.
Boolean := FuncObj.IsByRef(ParamIndex)
Type: Integer
If omitted, Boolean indicates whether the function has any ByRef parameters. Otherwise, specify the one-based index of a parameter.
Type: Integer (boolean)
This method returns 1 (true) if the parameter is ByRef, otherwise 0 (false). If ParamIndex is invalid, an exception is thrown.
Determines whether a parameter is optional.
Boolean := FuncObj.IsOptional(ParamIndex)
Type: Integer
If omitted, Boolean indicates whether the function has any optional parameters. Otherwise, specify the one-based index of a parameter.
Type: Integer (boolean)
This method returns 1 (true) if the parameter is optional, otherwise 0 (false). If ParamIndex is invalid, an exception is thrown.
Parameters do not need to be formally declared if the function is variadic. Built-in functions are supported.
Returns the function's name.
FunctionName := FuncObj.Name
Returns 1 (true) if the function is built-in, otherwise 0 (false).
Boolean := FuncObj.IsBuiltIn
Returns 1 (true) if the function is variadic, otherwise 0 (false).
Boolean := FuncObj.IsVariadic
Returns the number of required parameters.
ParamCount := FuncObj.MinParams
Returns the number of formally-declared parameters for a user-defined function or maximum parameters for a built-in function.
ParamCount := FuncObj.MaxParams
If the function is variadic, ParamCount indicates the maximum number of parameters which can be accepted by the function without overflowing into the "variadic*" parameter.