• <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
        • Break Statement
        • Do Statement
        • Exit Statement
        • For Statement
        • ForCase Statement
        • For (Dictionary) Statement
        • If Statement
        • Next Statement
        • Universe Statement
        • When Statement
        • While Statement
      • Assignment Statements
      • Data Entry Statements and Functions
      • 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>

Exit Statement

Format
exit ʃreturn_valueʅ;
Description
The exit statement terminates a procedure or user-defined function before normal processing is expected to end. When the statement is executed, processing stops for the current procedure or function, and control is passed to the next procedure or function.
When utilized in a user-defined function, an optional argument, return_value, sets the function's return value before exiting the function. The type of the argument, either a numeric or string expression, must match the function's return type.
Example 1
function numeric FirstWoman()

   
do numeric ctr = 1 while ctr <= HH_MEMBERS

       
if SEX(ctr) = 2 then
            FirstWoman = ctr;
           
exit; // exit the function, we've found our first woman!
        endif;

   
enddo;

    FirstWoman = 
0; // no woman was found

end;
Example 2
function string QueryForString(string message)

   
while 1 do

       
string response = prompt(message);

       
if response = "" then
           
errmsg("You cannot enter a blank value");

       
else
           
exit response;

       
endif;

   
enddo;

end;

// ...

errmsg("The non-blank value is %s", QueryForString("Enter a non-blank value"));
See also: Universe Statement, Skip Case Statement, Stop Function, EndCase Statement