Calling user-defined functions

Functions can be called in several ways.


1. Directly.


Directly called functions run synchronously. The caller macro/function waits until the called function returns.




FileRename a b

 member functions
Tray t
t.AddIcon(a b)



A special case of directly called functions are functions used with foreach.


See also: sub-functions


2. As callback function.


You give address of function A to function B. Then function B can call function A using the address. With some QM intrinsic functions instead of address can be used name or some other property.


Function A can be a user-defined function or a dll function, but cannot be a member, COM or QM intrinsic function. Function B can be any.


Function B can call function A immediately (eg EnumWindows), or set it to call later (eg SetTimer). COM event functions also are callback functions. Also there are functions that run in special threads (trigger filter functions and functions that run in QM main thread).


To call a user-defined function when you have its address or name, use call.




EnumWindows &enum_proc 0

SetTimer hDlg 1 1000 &MyTimerProc

x=ShowDialog("Dialog55" &Dialog55)

int fa=&my_callback_func
call fa 10 20

str fn="my_callback_func"
call fn 10 20

atend my_atend_func ;;with some QM intrinsic functions must be used function name without &



3. Special class member functions (constructor, destructor and operator=) are called implicitly. They run synchronously.


4. Thread entry functions. A thread entry function is a macro or function that has been launched using the Run button, a trigger, mac, or some other way if it caused to create new thread. Functions launched with mac run asynchronously. The macro/function that contains mac does not wait, unless it is explicitly programmed to wait.