Code: Difference between revisions
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
CODE | |||
The '''CODE''' [[internal function]] indicates the termination status of a [[program]] as set by the [[STOP]] or [[END]] [[statement]]. This completion code may be used in a [[procedure file]] with the [[SKIP]] [[command]] or it may be used in a subsequent program. | The '''CODE''' [[internal function]] indicates the termination status of a [[program]] as set by the [[STOP]] or [[END]] [[statement]]. This completion code may be used in a [[procedure file]] with the [[SKIP]] [[command]] or it may be used in a subsequent program. | ||
Line 7: | Line 8: | ||
008050 IF YEAR < 1987 THEN STOP 1122 | 008050 IF YEAR < 1987 THEN STOP 1122 | ||
Line | Line 8050 sets CODE to 1122. | ||
The procedure that runs these two programs could test the value of CODE with a SKIP command as follows: | The procedure that runs these two programs could test the value of CODE with a SKIP command as follows: |
Latest revision as of 17:03, 22 May 2014
CODE
The CODE internal function indicates the termination status of a program as set by the STOP or END statement. This completion code may be used in a procedure file with the SKIP command or it may be used in a subsequent program.
Comments and Examples
Suppose that a procedure normally runs two programs, but should not run the second program if there is a data entry error (e.g., invalid date) in the first program. The first program could set the CODE variable to a non- zero value if this type of error is detected. For example,
008050 IF YEAR < 1987 THEN STOP 1122
Line 8050 sets CODE to 1122.
The procedure that runs these two programs could test the value of CODE with a SKIP command as follows:
RUN PROGA SKIP 1 IF CODE>0 RUN PROGB
Related Functions
ERR is often tested in procedures in a similar way.
Technical Considerations
When the system call (either Ctrl-] or the System command) starts and then exits a secondary software program before returning to BR, the Code function will reflect any return code that the secondary program has passed to the operating system. As soon as BR is reactivated, the value of CODE can be tested to Verify whether or not the secondary program was successful.
This feature is available on Unix / Linux versions of Business Rules! only.