• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
      • Introduction to Data Entry
      • Data Entry Application
      • Data Entry Editing
        • Introduction to Data Entry Editing
        • Editing Concepts
        • Writing Logic
          • Data Entry Logic Screen Layout
          • Moving Around a Logic Application
          • Order of Executing Data Entry Events
          • Sequence Dictated by Designer
          • Run as Batch
      • CAPI Data Entry
      • Network Data Entry
      • Android Data Entry
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Order of Executing Data Entry Events

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:
  1. The inherent order imposed by the CSPro software design, and
  2. 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.
Form File preproc
    Level 1 preproc
        Form 1 preproc
        Form 1 onfocus
            Field 11 preproc
            Field 11 onfocus
            (entry of Field 11)
            Field 11 killfocus
            Field 11 postproc
            ...
            Field 19 preproc
            Field 19 onfocus
            (entry of Field 19)
            Field 19 killfocus
            Field 19 postproc
        Form 1 killfocus
        Form 1 postproc
        Form 2 preproc
        Form 2 onfocus
            Field 21 preproc
            Field 21 onfocus
            (entry of Field 21)
            Field 21 killfocus
            Field 21 postproc
            ...
            Field 29 preproc
            Field 29 onfocus
            (entry of Field 29)
            Field 29 killfocus
            Field 29 postproc
        Form 2 killfocus
        Form 2 postproc
    Level 2 preproc
        Form 3 preproc
        Form 3 onfocus
            Field 31 preproc
            Field 31 onfocus
            (entry of Field 31)
            Field 31 killfocus
            Field 31 postproc
            ...
            Field 39 preproc
            Field 39 onfocus
            (entry of Field 39)
            Field 39 killfocus
            Field 39 postproc
        Form 3 killfocus
        Form 3 postproc
    Level 2 postproc
    (repeat level 2 procedures for other level 2 nodes)
    Level 1 postproc
Form File postproc
Note that the natural flow through the fields can also be altered by the use of the cursor or mouse. For example:
Scenario 1
Given: Three fields (A, B, and C). From Field A, click on Field C. Assume all fields have preproc, onfocus, killfocus, and postproc events.

Result: Field A's killfocus would execute, but its postproc would not. Nothing would execute for Field B. Finally, Field C's preproc and onfocus would execute.
Scenario 2
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.
See also: CSPro Program Structure, Order of Executing Batch Edit Events