Setting up a User-programmed - TPABasic question
You write the code for a User-programmed question in the TPABasic code editor window. You write at a minimum certain functions having special names, and TPA calls or executes them. The one required function is eval . A template or skeleton for each of the user-provided routines can be inserted using the Templates button in the code editor window . Study the examples in the custom question file basic.qdb provided with TPA for more details. The TPA-specific functions in TPABasic are listed here .
The following is the scenario when a User-programmed question is executed.
Before any days are examined (the pre-evaluation phase, executed once):
If the function beforeBanner exists, it is used to put a banner message on the Search Progress meter.
If the function beforeEval exists and returns a false value, the evaluation phase is skipped and we proceed straight to "After all days are examined" below.
For every day in the collection (the evaluation phase, executed many times, once for each day):
If the function eval returns true, the current day is included in the search result, otherwise it is not.
If the function abortEval exists and returns a true value, the rest of the evaluation phase is skipped and we proceed straight to "After all days are examined" below.
After all days are examined (the post-evaluation phase, executed once):
If the subroutine afterEval exists, it is executed.
If the function displayString exists, it is executed and the return (string) value is shown as the question description in the Search Results window.