Microsoft KB Archive/64209

How to Scroll Text in a COBOL Program Using Interrupts

PSS ID Number: Q64209 Article last modified on 07-27-1990

3.00 3.00a MS-DOS

Summary: Microsoft COBOL versions 3.00 and 3.00a programs can scroll text up and down in a window on the screen by calling interrupt X“10”, functions X“06” and X“07” under MS-DOS. This information applies to Microsoft COBOL Compiler versions 3.00 and 3.00a for MS-DOS.

More Information: COBOL 3.00 and 3.00a can call interrupts via the special subprogram X“84”. Function X“06” of interrupt X“10” scrolls text up, function X“07” scrolls text down. Both functions require that the registers be set as follows:

The BH register specifies the attribute to use for the new lines created behind the scrolling text. The characters for these lines are always blanks. Registers CH, CL, DH, and DL define the rectangular window on the screen where the scrolling will take place. Any area outside this rectangle is not scrolled. If the number of lines to scroll (AL) is set to 0, the entire window is blanked. For more information about calling interrupts from COBOL 3.00 and 3.00a, see Pages 8-4 and 8-5 of the “Microsoft COBOL 3.0: Operating Guide.” For more information about functions X“06” and X“07” of interrupt X“10”, see Pages 505-506 of “Advanced MS-DOS Programming, Second Edition,” by Ray Duncan (Microsoft Press, 1988). The following program (SCROLL.CBL) displays a message on the screen and allows you to scroll the message up and down using the cursor keys. Any part of the message that is scrolled off the screen is lost. To compile and link the program, enter the following lines at the DOS command prompt: cobol scroll; link scroll; NOTE: This sample program has failed on PS/2 machines and some clone VGA cards. It requires a very IBM-compatible card. If you encounter problems such as screen blanking or garbage on the screen, turn off any switches on the card that enable advanced features such as automatic mode switching, SuperVGA, etc. Microsoft makes no claims or guarantees as to whether this example will work with your particular video card.

Code Example
$SET ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. Scroll. DATA DIVISION. WORKING-STORAGE SECTION. 01 AX. *  Will specify either function 6 or 7. 05 A-H       PIC 99 COMP-X. *  Specifies to scroll one line at a time. 05 A-L       PIC 99 COMP-X VALUE 1. 01 BX. *  Specifies attribute of white on black. 05 B-H       PIC 99 COMP-X VALUE 15. 05 B-L       PIC 99 COMP-X. *  Specifies absolute upper-left corner of screen. 01 CX. 05 C-H       PIC 99 COMP-X VALUE 0. 05 C-L       PIC 99 COMP-X VALUE 0. *  Specifies absolute lower-right corner of screen (assuming  *   80 columns by 25 rows). 01 DX. 05 D-H       PIC 99 COMP-X VALUE 24. 05 D-L       PIC 99 COMP-X VALUE 79. *  Specifies interrupt X&quot;10&quot;. 01 Interrupt    PIC X         VALUE X&quot;10&quot;. *  Specifies to load registers with value of parameters. 01 Flag         PIC X         VALUE X&quot;FF&quot;. *  Used to poll status of/get characters from keyboard. 01 KeyStatus    PIC 99   COMP-X. PROCEDURE DIVISION. *   Clear screen and display message. CALL X&quot;E4&quot;. DISPLAY &quot;SCROLL ME&quot;. DISPLAY &quot;HIT ESCAPE TO EXIT&quot;. *   Loop until the ESC key is pressed. PERFORM UNTIL KeyStatus = 27 *      Loop until user presses a key. MOVE 0 TO KeyStatus PERFORM UNTIL KeyStatus NOT = 0 CALL X&quot;D9&quot; USING KeyStatus END-PERFORM *      Get first byte from keyboard buffer. CALL X&quot;83&quot; USING KeyStatus *      If first byte is null, a cursor key might have been hit. IF KeyStatus = 0 THEN *         Get second byte from keyboard buffer. CALL X&quot;83&quot; USING KeyStatus *         Check if the up or down cursor keys were pressed, *         and if so, scroll the window (the entire screen in   *          this case) one row in the appropriate direction. EVALUATE KeyStatus WHEN 72 MOVE 6 TO A-H CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX            WHEN 80 MOVE 7 TO A-H CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX            END-EVALUATE END-IF END-PERFORM. STOP RUN. Copyright Microsoft Corporation 1990.