Call function by address

Syntax

int call(address [a1 ...])

 

Parameters

address - function address. It can be a user-defined function, dll function, sub-function or other code. For user-defined functions, you can also use function's name as string, or QM item id.

a1 ... - arguments.

 

Remarks

Calls a function by address, not by name. It allows you to choose a function at run time. For example, you can use it to call a callback function. Use operator & to get function address.

 

Returns called function's return value, which must be of type int.

 

Argument types and number must match exactly. They are not converted. Composite types (str, interface pointers, etc) cannot be passed by value. Variables passed by reference must be with operator &, like &var.

 

Callback functions should handle errors (use err if need). On unhandled error the thread ends, even if the caller uses err to handle errors.

 

See also: IsValidCallback.

 

Example

 Function MyFunction:
function# int'i str&s
...
 ________________________________

 Call MyFunction in usual way:
str s="string"
int r = MyFunction(1 s)

 Call myfunction with call:
str s="string"
int fa = &MyFunction
int r = call(fa 1 &s)
 or
str fn = "MyFunction"
r = call(fn 1 &s)
 or
int iid = qmitem("MyFunction")
r = call(iid 1 &s)