An "event" is a unit of logic associated with an element of the edit tree, such as a form, a field, etc. The order in which events are executed during data entry is dependent on two factors:
- The inherent order imposed by the CSPro software design, and
- The order in which data items are entered, which is determined by the designer of the application
CSPro is based on the concept of a "case" containing one or more types of "collections of information." The "case" will usually correspond to the questionnaire used in the survey or census, and the "collections of information" [or groups of data items] will usually correspond to one or more record types that make up the case/questionnaire. These elements constitute a hierarchy, and in applying logic, CSPro follows this hierarchy; that is, it begins with any logic that pertains to the file itself, and works "down the tree" through the various levels. CSPro executes application events one case at a time. During data entry,
preproc,
onfocus,
onoccchange,
killfocus and
postproc statements are executed in the order in which they are encountered.
The following diagram illustrates the default order of events for a two-level data entry application that has no
skip or
advance statements that might otherwise alter the program's natural flow. Level 1 has two forms (1 and 2) and level 2 has one form (3). This description applies to both system- and operator-controlled applications.
Note that the natural flow through the fields can also be altered by the use of the cursor or mouse. For example:
Given: Form 1, which contains one field, Field 1. Form 2, which also contains one field, Field 2. After keying Field 1, you are automatically advanced to Form 2, Field 2. You then decide to use the up/left arrow to move back to Form 1. Assume both forms and both fields have
preproc,
onfocus,
killfocus, and
postproc events.
Result: Field 2's
killfocus would execute, but its
postproc would not. Next, Form 1's
onfocus would execute. Finally, Field 1's
onfocus would execute (but its
preproc would not). Note that it does not matter how many fields are on Form 1; the
onfocus for Form 1 would always execute.
Essentially, if the programmer uses logic, or if the data entry operator moves backwards or forwards with the mouse or arrow keys, the natural flow of the program will be altered. If exiting a form, field, or roster prematurely, the
killfocus event will execute but the
postproc event will not. Similarly, if entering a form, field, or roster by backing up into it, the
onfocus event will execute but the
preproc event for it will not.