Establish flags, set them to true and false, and then test them.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
Syntax:
TRUE|FALSE dataname1 [dataname2 [... datanameN]]
General Rules:
- For each
dataname coded, S-COBOL provides an 02-level conditional variable and an associated 88-level condition name entry in an 01 GENERATED-FLAGS area of Working-Storage. AMB adds a --FLG suffix to
dataname to create the 02-level entry, and
dataname itself becomes the 88-level entry. AMB always assigns VALUE 'T' to the 88-level condition name, never VALUE 'F'. For example
The following code in the Procedure Division
.
.
TRUE THERE-ARE-NO-ERRORS
FALSE WITHIN-RANGE
.
.
.
Generates
WORKING-STORAGE SECTION.
.
.
02 THERE-ARE-NO-ERRORS--FLG PIC X.
88 THERE-ARE-NO-ERRORS VALUE 'T'.
02 WITHIN-RANGE--FLG PIC X.
88 WITHIN-RANGE VALUE 'T'.
- If, for debugging purposes, you want to display a generated flag, add the --FLG suffix to
dataname in the DISPLAY statement. For example, TRUE THERE-ARE-NO-ERRORS generates MOVE TRUE TO THERE-ARE-NO-ERRORS--FLG.
- If only true statements, such as TRUE WITHIN-RANGE, or only false statements, such as FALSE WITHIN-RANGE, are coded for
dataname, a warning message indicates a logic error.
- S-COBOL minimizes the code required to test the flags established and set by the TRUE/FALSE verbs.
- Code WHILE THERE-ARE-NO-RECORDS instead of WHILE THERE-ARE-NO-RECORDS--FLG = TRUE.
- Code IF NOT WITHIN-RANGE instead of IF WITHIN-RANGE--FLG = FALSE.
Example:
Set two undefined flags, THERE-ARE-NO-ERRORS and WITHIN-RANGE to TRUE (line 3030). Define these flags in Working-Storage (88-level condition name flags), because this is the first TRUE or FALSE statement for either flag in this program. If the condition in line 3060 is true, set the THERE-ARE-NO-ERRORS flag to FALSE. If either condition in line 3110 is true, set the WITHIN-RANGE flag to FALSE. As long as the value of the THERE-ARE-NO-ERRORS flag is TRUE, perform the loop. Inside the loop test the other flag, WITHIN-RANGE. If the value is TRUE, execute the subordinate statement block.
.
003030 TRUE THERE-ARE-NO-ERRORS
003031 ... WITHIN-RANGE
.
003060 IF CODE-IN NOT NUMERIC
003070 FALSE THERE-ARE-NO-ERRORS
.
003110 IF COUNT > 372 OR COUNT < 50
003120 FALSE WITHIN-RANGE
.
003150 WHILE THERE-ARE-NO-ERRORS
003160 IF WITHIN-RANGE