The procedure must match the same Sub declaration as the declared Sub pointer.

To call the subroutine assigned, use the variable name as if it were a normal declared Sub.

One of the primary uses for procedure pointers is to create callback procedures. A callback procedure is a procedure created in the user program that is called by another procedure either from the user own code space or from an external library.

' Example of advanced callback Sub mechanism to implement a key pressed event:' (the user callback Sub address can be modified while the event thread is running)' - An asynchronous thread tests the keyboard in a loop, and calls a user callback Sub each time a key is pressed.' - An UDT groups the common variables used (callback Sub pointer, character of key pressed, thread end flag),' and the static thread Sub plus the thread handle.' - An UDT instance pointer is passed to the thread, which then transmits it to the callback Sub each time.' - The callback Sub prints the character of the key pressed character,' but if the key pressed is <escape> it orders the thread to finish.' - As the user callback pointer is a member field of the UDT, it can be modified while the thread is running.