• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
      • Introduction to CSPro Language
      • CSPro Program Structure
      • Programming Standards
      • Change Code Properties
      • Code Folding
      • Debugging CSPro Applications
      • Declaration Section
      • Procedural Sections
      • Logic
        • View Logic
        • Create and Edit Logic
        • Find and Replace Logic
        • Compile Logic / An Application
        • OnKey Character Map
        • OnViewQuestionnaire Global Function
        • User and Configuration Settings
        • String Encoder Dialog
        • Path Adjuster Dialog
        • Symbol Analysis
      • Language Elements
      • JavaScript Use in CSPro
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Create and Edit Logic

You can use the CSPro language to write logic for virtually any part of your data entry or batch edit application: a level, roster, form, or field. In a data entry application you must make sure the screen has the logic view on the right and the data entry tree on the left, so you can click on the item for which you want to write logic. You can see the logic for the whole application by clicking on the forms file (usually the topmost node) on the data entry or batch edit tree.
Example: Programming a Message for the Keyer
Give a message for the keyer if there are married (or previously married) people under the age of 12. Click on the "Marital Status" field on the forms tree, P06_MARITAL_STATUS in our example. In the text editor, at the top of the logic view, you will see:
PROC P06_MARITAL_STATUS
Now enter the following:
if P06_MARITAL_STATUS <> 1 and P05_AGE < 12 then
   
errmsg("Not 'never married' but less than 12 years old");
endif;
Note that this particular verification can be done only after data has been entered in both fields. If for some reason AGE is captured after P06_MARITAL_STATUS, then these instructions would be placed in the AGE field's logic.
Example: Programming a Skip
Program a skip after the marital status question to skip over "Age at First Marriage" if the person is never married. Click on the "Marital Status" field on the forms tree, P06_MARITAL_STATUS in our example. In the text editor, at the top of the logic view, enter:
PROC P06_MARITAL_STATUS

   
if P06_MARITAL_STATUS = 1 then
       
skip to P08_WORK_STATUS;
   
endif;