opencobol - How to clear screen and set cursor position to the end of the screen in cobol -
so i'm trying make form-like screen user inputs data , saves in .txt file. i'm using opencobolide , i'm going through problems in clearing screen process. have kind of form made in console screen , when user enters data im refreshing new values of variables, cursor position screwing me because after clear screen gets reseted beginning of console screen, , want go end of text i'm displaying after process. explanation may confusing hope point code:
identification division. program-id.pgm001. environment division. data division. working-storage section. 01 ws-data 02 ws-id pic x(03) value spaces. 02 ws-name pic a(15) value spaces. 02 ws-phone pic x(09) value spaces. screen section. 01 clear-screen. 02 blank screen. procedure division. menu. display "id........:" ws-id. display "name......:" ws-name. display "phone.....:" ws-phone. display "-----------". display "id:". accept ws-id console. display clear-screen. display "id........:" ws-id. display "name......:" ws-name. display "phone.....:" ws-phone. display "-----------". display "name:". accept ws-name console. display clear-screen. display "id........:" ws-id. display "name......:" ws-name. display "phone.....:" ws-phone. display "-----------". display "phone:". accept ws-phone console. display clear-screen. display "id........:" ws-id. display "name......:" ws-name. display "phone.....:" ws-phone. display "-----------". stop run. end-program pgm001.
so you'll notice keep clearing screen , displayin form cursor goes beginning of screen , can't keep inputing data. can me please? there command in cobol moves cursor?
in cobol, there 2 types of display statement: device , screen.
in opencobol, device , screen displays cannot used @ same time; if try to, find there no output device displays after first screen display. happening example: clear-screen
defined in screen section, display clear-screen
screen display.
you can fix defining entry form in screen section:
screen section. 01 form blank screen. 03 value "id.........". 03 col + 2, pic x(03) ws-id. 03 line + 1, value "name.......". 03 col + 2, pic a(15) ws-name. 03 line + 1, value "phone......". 03 col + 2, pic x(09) ws-phone. 03 line + 1, value "-----------".
as working, has advantage procedure division can reduced to
display form accept form
as form data can entered in 1 go.
if, however, want keep data entry is, can turn device displays screen displays adding at line <line-num>
:
display "id........:" ws-id @ line 1 display "name......:" ws-name @ line 2 display "phone.....:" ws-phone @ line 3 display "-----------" @ line 4 display "id:" @ line 5 accept ws-id @ line 5, col 5
Comments
Post a Comment