Introduction
The following describes the required logic for the on execute hooks.
Note: Error handling is limited in the example code, to keep
the basic logic clear. For the same reason subfunctions are used. Note that
these are non-standard functions, which can only be used if they are
implemented in a library (or a define inside the hook).