Microsoft KB Archive/50006

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:24, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q50006 to Microsoft KB Archive/50006 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Example and Explanation of COBOL 3.0 Reference Modification

PSS ID Number: Q50006 Article last modified on 04-20-1993

3.00 3.00a MS-DOS

The information in this article applies to:
- Microsoft COBOL for MS-DOS, versions 3.0 and 3.0a

Summary: In Microsoft COBOL Compiler Version 3.0 or 3.0a, reference modification defines a data item by specifying a leftmost character and length for the data item. In general, reference modification is allowed where any identifier referencing an alphanumeric data item is permitted. Reference modification adds flexibility to COBOL code by allowing the programmer to access, move, and use data without the need to define several sublevels in the file record definition. Reference modification is an ANSI 85 directive.

More Information: Reference modification assigns to a data item either all or part of another data item’s value. Its action simulates the BASIC MID$ function. Reference modification will work on all alphanumeric data types that are of the same type. The process thus parses information from one data item to another and creates a subset data value. The general format for reference modification is DATA-NAME (LEFTMOST-CHARACTER-POSITION : LENGTH) where DATA-NAME is either a qualified or subscripted data item and LEFTMOST-CHARACTER-POSITION and LENGTH are arithmetic expressions, either numeric literals or variables.

Code Example

  $SET ANS85
   DATA DIVISION.
   WORKING-STORAGE SECTION.
   77 MESSAGE1            PIC X(20) VALUE
             'The entire message'.
   77 MESSAGE1-PART       PIC X(10).
   77 VAR1                PIC 9(5) VALUE 12.
   PROCEDURE DIVISION.
   MAIN.
       DISPLAY MESSAGE1 AT 0501.
       MOVE MESSAGE1 (VAR1:7) TO MESSAGE1-PART.
       DISPLAY MESSAGE1-PART AT 0701.
   STOP RUN.

The following is the output of this program: The entire message message

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.