Func Object [v1.1.00+]

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. Func() returns an object of this type.

For information about other objects which can be called like functions, see Function Objects.

A reference to a Func object is also known as a function reference. To retrieve a function reference, use the Func function as in the following example:

; Retrieve a reference to the function named "StrLen".
fn := Func("StrLen")

; Display information about the function.
MsgBox % fn.Name "() is " (fn.IsBuiltIn ? "built-in." : "user-defined.")

Table of Contents

Methods

Call

Calls the function.

Func.Call(Param1, Param2, ...)  ; Requires [v1.1.19+]
Func.(Param1, Param2, ...)  ; Old form - deprecated

Parameters

Param1, Param2, ...

Parameters and return value are defined by the function.

Remarks

[v1.1.07+]: %Func%() can be used to call a function by name or reference, or to call an object which implements the __Call meta-function. This should be used instead of Func.() wherever possible.

Bind [v1.1.20+]

Binds parameters to the function.

BoundFunc := Func.Bind(Param1, Param2, ...)

Parameters

Param1, Param2, ...

Any number of parameters.

Return Value

This method returns a BoundFunc object.

IsByRef

Determines whether a parameter is ByRef.

Boolean := Func.IsByRef(ParamIndex)

Parameters

ParamIndex

If omitted, Boolean indicates whether the function has any ByRef parameters. Otherwise, specify the one-based index of a parameter.

Return Value

This method returns an empty string if the function is built-in or ParamIndex is invalid; otherwise, a boolean value indicating whether the parameter is ByRef.

IsOptional

Determines whether a parameter is optional.

Boolean := Func.IsOptional(ParamIndex)

Parameters

ParamIndex

If omitted, Boolean indicates whether the function has any optional parameters. Otherwise, specify the one-based index of a parameter.

Return Value

This method returns an empty string if ParamIndex is invalid; otherwise, a boolean value indicating whether the parameter is optional.

Remarks

Parameters do not need to be formally declared if the function is variadic. Built-in functions are supported.

Properties

Name

Returns the function's name.

FunctionName := Func.Name

IsBuiltIn

Returns 1 (true) if the function is built-in, otherwise 0 (false).

Boolean := Func.IsBuiltIn

IsVariadic

Returns 1 (true) if the function is variadic, otherwise 0 (false).

Boolean := Func.IsVariadic

MinParams

Returns the number of required parameters.

ParamCount := Func.MinParams

MaxParams

Returns the number of formally-declared parameters for a user-defined function or maximum parameters for a built-in function.

ParamCount := Func.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.

Functions

Func [v1.1.00+]

Retrieves a reference to a function.

FunctionReference := Func(FunctionName)

Parameters

FunctionName

The name of the function whose reference is retrieved. The function must exist explicitly in the script.

Return Value

Func returns a reference to FunctionName. If FunctionName does not exist explicitly in the script (by means such as #Include or a non-dynamic call to a library function), it returns 0.

Remarks

Func can be used to call the function or retrieve information such as the minimum and maximum number of parameters.

The following example retrieves a reference to a function and displays information about it:

fn := Func("StrLen")
MsgBox % fn.Name "() is " (fn.IsBuiltIn ? "built-in." : "user-defined.")