Func Object

Auto Hotkey

Func Object

Represents a user-defined or built-in function which can be called by the script.

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.")

If fn is a function reference, Func(fn) returns it. Thus, fn := Func(fn) can be used to ensure fn is a function reference. If fn is neither a valid function name nor a function reference, Func returns a blank value.

Call

Calls the function.

Func.Call(Parameters)
%Func%(Parameters)

The second form (a dynamic function call) also works with function names (strings) and other kinds of function objects.

Parameters and return value are defined by the function.

Bind

Binds parameters to the function and returns a BoundFunc object.

BoundFunc := Func.Bind(Parameters)

Parameters can be any number of parameters.

For details and examples, see BoundFunc object.

Name

Returns the function's name.

Func.Name

IsBuiltIn

Returns true if the function is built-in and false otherwise.

Func.IsBuiltIn

IsVariadic

Returns true if the function is variadic and false otherwise.

Func.IsVariadic

MinParams

Returns the number of required parameters.

Func.MinParams

MaxParams

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

Func.MaxParams

If the function is variadic, the return value indicates the maximum number of parameters which can be accepted by the function without overflowing into the "variadic*" parameter.

IsByRef()

Determines whether a parameter is ByRef.

Func.IsByRef(ParamIndex)
ParamIndexOptional: the one-based index of a parameter. If omitted, the return value indicates whether the function has any ByRef parameters.
ReturnsAn 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.

Func.IsOptional(ParamIndex)
ParamIndexOptional: the one-based index of a parameter. If omitted, the return value indicates whether the function has any optional parameters.
ReturnsAn empty string if ParamIndex is invalid; otherwise, a boolean value indicating whether the parameter is optional.

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