Microsoft KB Archive/40033

How to Use Subscripted Data Items in the SCREEN SECTION

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

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: Microsoft COBOL Versions 3.0 and 3.0a allow you to use subscripted data items (which are also known as tables, or arrays) in the SCREEN SECTION for data items specified in the TO, FROM, and USING clauses. This feature was not available in previous versions of Microsoft COBOL.

More Information: Subscripted data items can be used to define a small screen in the SCREEN SECTION and use it to display a table with a minimum amount of coding. The following code example demonstrates how to display a table of three data items that occur eight times using a screen definition that only defines one line. The following are the compile and LINK command lines: COBOL displayt; LINK displayt+adis+adisinit+adiskey,,,lcobol.lib; Here is the code example:

$SET ANS85 BOUND WORKING-STORAGE SECTION. 01 NAME-LIST. 05  FILLER       PIC X(21) VALUE &quot;DONALD    D DUCK&quot;. 05  FILLER       PIC X(21) VALUE &quot;DAFFY     B DUCK&quot;. 05  FILLER       PIC X(21) VALUE &quot;MICKEY    M MOUSE&quot;. 05  FILLER       PIC X(21) VALUE &quot;ELMER     E FUDD&quot;. 05  FILLER       PIC X(21) VALUE &quot;SYLVESTER T CAT&quot;. 05  FILLER       PIC X(21) VALUE &quot;POKEY     T PONY&quot;. 05  FILLER       PIC X(21) VALUE &quot;GUMBY     T STRETCH&quot;. 05  FILLER       PIC X(21) VALUE &quot;PORKEY    P PIG&quot;. 01 PRINT-LIST REDEFINES NAME-LIST. 05 PRINT-TABLE OCCURS 8 TIMES. 07   FIRST-NAME     PIC X(10). 07   MIDDLE-NAME    PIC X.              07    LAST-NAME      PIC X(10). 01 NAME-1                PIC 9     VALUE 1. 01 LINE-NO               PIC 99    VALUE 3. SCREEN SECTION. 01  BLANK-SCREEN. 05 BLANK SCREEN. 01  DISPLAY-NAMES. 05 LINE LINE-NO COLUMN 5 PIC X(10) FROM FIRST-NAME(NAME-1). 05 LINE LINE-NO COLUMN 16 PIC X FROM MIDDLE-NAME(NAME-1). 05 LINE LINE-NO COLUMN 18 PIC X(10) FROM LAST-NAME(NAME-1). PROCEDURE DIVISION. DISPLAY BLANK-SCREEN. PERFORM 8 TIMES DISPLAY DISPLAY-NAMES ADD 1 TO NAME-1 ADD 2 TO LINE-NO END-PERFORM. STOP RUN. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.