Search code examples
cobolgnucobol

COBOL: How to turn off SCREEN and come back to terminal


I'm displaying to user a form, defined in SCREEN SECTION. After user input I'd like to clear the screen and go back to terminal. But I have no idea how to do it. Every next DISPLAY "something" puts data back at first row of screen. I don't want to use SCREEN anymore, no LINE statements.

[...]

SCREEN SECTION.
01 USER-FORM.
[...]
01  CLEAR-SCREEN.
    05 BLANK SCREEN.

[...]

DISPLAY USER-FORM.
ACCEPT USER-FORM.
DISPLAY CLEAR-SCREEN.

PERFORM DATA-CALCULATIONS.

DISPLAY "CALCULATION RESULTS 1: " WS-DATA(1).
DISPLAY "CALCULATION RESULTS 2: " WS-DATA(2).
DISPLAY "CALCULATION RESULTS 3: " WS-DATA(3).


Solution

  • You can't. Once you've used a SCREEN in GnuCOBOL, all subsequent DISPLAYs/ACCEPTs are on the screen.

    If you don't want to explicitly specify the LINE and COL for the subsequent DISPLAYs, you can use LINE 0 extension, which gives something like the usual DISPLAY behaviour (namely, LINE 0 positions the DISPLAY at the start of the line following the last ACCEPT/DISPLAY).

    DISPLAY "CALCULATION RESULTS 1: " LINE 0, WS-DATA(1).
    DISPLAY "CALCULATION RESULTS 2: " LINE 0, WS-DATA(2).
    DISPLAY "CALCULATION RESULTS 3: " LINE 0, WS-DATA(3).