Microsoft KB Archive/58925
Reference Modification as Condition Requires NOOSVS Directive
PSS ID Number: Q58925 Article last modified on 02-28-1990
3.00 3.00a | 3.00 3.00a MS-DOS | OS/2
Summary: Reference modification is a COBOL method to parse part of a variable’s value for assignment or comparison to another variable. To use reference modification as an assignment, no directives need to be specified. To use reference modification as a conditional expression, however, the directive NOOSVS must be set. For more information on reference modification, query on the following keywords: reference and modification and example This information applies to Microsoft COBOL Compiler Versions 3.00 and 3.00a for MS-DOS and MS OS/2.
More Information: The three methods to set COBOL directives are listed below. Directives set in the COBOL.DIR file have the least authority and can be changed by directives set at either the DOS command line or in the COBOL source file. Directives set in the source file have the highest precedence. 1. Directives set in the file COBOL.DIR (lowest precedence) 2. Directives set at the command line 3. Directives set in the COBOL source file (highest precedence) The program examples below illustrate the above discussion. If the $SET NOOSVS directive in the second example is commented out and this directive is set nowhere else, the error “Invalid Operand” is returned by the COBOL.EXE compiler.
Program Example 1
DATA DIVISION. WORKING-STORAGE SECTION. 77 MESSAGE1 PIC X(20) VALUE 'The entire message'. 77 MESSAGE1-PART PIC X(10). * PROCEDURE DIVISION. MAIN. DISPLAY MESSAGE1 AT 0501. MOVE MESSAGE1 (12:7) TO MESSAGE1-PART. DISPLAY MESSAGE1-PART AT 0701. STOP RUN.
Program Example 2
$SET NOOSVS DATA DIVISION. WORKING-STORAGE SECTION. 77 MESSAGE1 PIC X(20) VALUE 'The entire message'. 77 MESSAGE1-PART PIC X(20) VALUE 'Not working'. * PROCEDURE DIVISION. MAIN. DISPLAY MESSAGE1 AT 0501. if (MESSAGE1 (1:1) = "T") THEN MOVE MESSAGE1 (12:7) TO MESSAGE1-PART. DISPLAY MESSAGE1-PART AT 0701. STOP RUN.
Copyright Microsoft Corporation 1990.