• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
        • Accept Function
        • Advance Statement
        • Ask Statement
        • ChangeKeyboard Function
        • Connection Function
        • DeMode Function
        • Display Orientation
        • EditNote Function
        • EndLevel Statement
        • EndGroup Statement
        • Enter Statement
        • GetCaptureType Function
        • GetCaseLabel Function
        • GetDeviceID Function
        • GetImage Function
        • GetNote Function
        • GetOperatorId Function
        • GetOS Function
        • GetRecord Function
        • GetUserName Function
        • GPS Function
        • Interactive GPS Modes
        • HideOcc Function
        • Highlighted Function
        • InAdvance Function
        • IsPartial Function
        • IsVerified Function
        • Move Statement
        • NoInput Statement
        • OnChangeLanguage Global Function
        • OnChar Global Function
        • OnKey Global Function
        • OnStop Global Function
        • OnSystemMessage Global Function
        • Prompt Function
        • Protect Function
        • PutNote Function
        • RandomizeVS Function
        • Reenter Statement
        • SavePartial Function
        • SelCase Function
        • Set Attributes Statement
        • Set Behavior CanEnter Statement
        • SetCapturePos Function
        • SetCaptureType Function
        • SetCaseLabel Function
        • Set ErrMsg Statement
        • SetFont Function
        • SetOperatorId Function
        • Show Function
        • ShowArray Function
        • ShowOcc Function
        • Skip Statement
        • Userbar Function
        • VisualValue Function
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization 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>

OnStop Global Function

Format
function OnStop();
Description
OnStop is a special global function. It has no return value and must be placed in the PROC GLOBAL section just like any other user-defined function.
When defined, it provides control over what happens when the data entry operator tries to stop data entry by pressing the ESC key, the Stop button, Ctrl+S, or attempting to exit data entry. When any of the above events occur, the OnStop function is executed, with no stop dialog (discard, save, cancel) appearing.
The OnStop function can be used to prevent the operator from stopping data entry (see Example 1 below) or to allow stopping data entry only under certain conditions (see Example 2 below).
Be aware that if you have added an OnStop function to your data entry application, then when a partial case is resumed, no resume dialog ("Do you want to go to last...") appears. Therefore if you wish for this feature to be available to your interviewers, you must code it yourself (see Example 3 below).
Similarly, if special actions are required when resuming a partial case, check whether a partial case has been entered by using the ispartial function, and then add the appropriate logic.
The OnStop function is not executed when the stop function is executed.
Example 1
PROC GLOBAL

function OnStop()
   
reenter;
end;
Example 2
PROC GLOBAL

function OnStop()
   
if getsymbol() in "FIRST_NAME", "LAST_NAME" then
       
reenter;
   
else
       
savepartial();
       
stop(1);
   
endif;
end;
Example 3
As mentioned above, when OnStop is defined in an entry application, you must write your own logic to resume from a partial save. However, this is only possible in one-level applications, as the name and occurrence number of the last field entered is not retrievable in two-level entry applications.
string last_field_entered = getsymbol(savepartial);
numeric choice;

if last_field_entered <> "" then

    choice = 
errmsg("Do you want to resume where you left off?")
                   
select("Yes", continue,
                           
"No", continue);
   
if choice = 1 then
       
advance to last_field_entered;
   
endif;
endif;
See also: User-Defined Functions, Function Statement, Stop Function, SavePartial Function, IsPartial Function, EndLevel Statement