# EXIT

Syntax:

Then: EXIT num_expr

"num_expr" is the program's exit value.

NOTE: The exit value must be between 0 and 255, inclusive. Standard practice is to use zero as a success indicator, and other values to indicate failure.

Version Ref: 4.5

Description:

Terminates running of the filePro program and sets the exit value.

EXIT records the data up to the point in the table at which it is encountered and takes the user completely out of Inquire, Update, Add or Request Output.

When used in Request Output, all records that have been processed before the EXIT occurs are printed.

Note: The current record is written out first as is.

Retrieving the exit value

EXIT is used in conjunction with a batch files or script files.

MS-DOS, the programs exit value can be checked by using the "IF ERRORLEVEL" batch command.

Unix, you can use "if dclerk ..." to check for success or failures, or you can check "$?" for specific values.

Indicate & test failure.

Example:

Assume the following code is on a report that is at the head of a long group of reports. You only want to run the rest of the reports if this one runs correctly. The menu script might look something like this. Remember - the filePro code shown is really on "report1" and returns to the environment a good or bad status. The "if $?..." line is how you test whether this report failed or not. If it fails, i.e., if the exit value is not 0, the "exit" command (this time the Unix shell's version of exit) takes you completely out of the script and the following reports do not get executed. Otherwise, the test falls through, and the reports run.

/appl/fp/dreport firstfile -f report1 -a ...
Then: rn(1,.0)="1"
Then: lookup control r=rn -nx
If: not control
Then: errorbox "Cannot read control file!" ; exit "127"
Then: exit "0"
f $? != "0" && exit
/appl/fp/dreport otherfile -f otherreport2
/appl/fp/report thatfile -f otherreport3
/appl/fp/dreport samefilefile -f otherreport4