Microsoft KB Archive/39364

How to Position the Cursor in COBOL Version 3.0

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

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

Summary: The CURSOR IS clause, which appears in the SPECIAL-NAMES SECTION, allows you to position the cursor in the field of your choice at the start of ACCEPT statement. The last location of the cursor is recorded in the CURSOR IS data group after the ACCEPT. This feature is used in conjunction with the SCREEN SECTION.

More Information: The example program below demonstrates how to use the CURSOR IS clause. To position the Cursor, move the line and column values to the Cursor-Row and the Cursor-Column fields prior to the ACCEPT statement. If the values moved into the data item identified by the CURSOR IS clause are not valid field values, the cursor will be positioned at the beginning of the first field in the ACCEPT screen. The following code example shows how to position the cursor on the last field. It may be compiled and LINKed accepting the defaults:

$set ANS85 SPECIAL-NAMES. CURSOR IS CURSOR-POSITION. WORKING-STORAGE SECTION. 01 Cursor-Position. 03 Cursor-Row         PIC 99. 03 Cursor-Column      PIC 99. 01 SCREEN-FIELDS. 03 WS-NAME         PIC X(20)     VALUE &quot;JOHN DOE&quot;. 03 WS-STREET       PIC X(20)     VALUE &quot;EASY STREET&quot;. 03 WS-STATE        PIC X(2)      VALUE &quot;WA&quot;. SCREEN SECTION. 01 DISPLAY-SCREEN. 03       BLANK SCREEN. 03       LINE 3 COLUMN 4             VALUE &quot;NAME:&quot;. 03       LINE 3 COLUMN 15 PIC X(20)  USING WS-NAME. 03       LINE 5 COLUMN 4             VALUE &quot;STREET:&quot;. 03       LINE 5 COLUMN 15 PIC X(20)  USING WS-STREET. 03       LINE 7 COLUMN 4             VALUE &quot;STATE:&quot;. 03       LINE 7 COLUMN 15 PIC X(2)   USING WS-STATE. PROCEDURE DIVISION. MAIN. MOVE 7 TO Cursor-Row. MOVE 15 TO Cursor-Column. DISPLAY DISPLAY-SCREEN. ACCEPT DISPLAY-SCREEN. STOP RUN. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.