Menu

#946 ERROR on DISPLAY STATEMENT

unclassified
not-our-bug
Chuck H.
5 - default
2024-06-15
2024-02-10
No

The following example program requires typing two fields on the screen, a name and a code.
If nothing is typed then it displays an error message requiring you to type the single field.
See screenshot.

To view the bug, proceed as follows.

a. When the program asks you to type the name, do not type anything but just press Enter see ERR10.PNG
b. The system displays the error message (using some DISPLAYS) see ERR20.PNG
c. Press Enter again to exit from the message
d. The system prompts you to enter the Name field again
e. do not type anything but just press Enter again
f. The program should display the same error message again.
g. The program executes the same DISPLAY statements again but this time the message is not displayed on the screen.
How come ?

       >>SOURCE FORMAT IS FREE
       REPLACE ==:BCOL:== BY ==with BACKGROUND-COLOR==
               ==:FCOL:== BY ==FOREGROUND-COLOR==.
IDENTIFICATION DIVISION.
program-id. TESTERROR.

ENVIRONMENT DIVISION. 
Configuration Section.
 SPECIAL-NAMES.
   CRT STATUS IS wKeyPressed.

DATA DIVISION.
*> **************************************************************
WORKING-STORAGE SECTION.
*> **************************************************************
  01 Black        constant as 00.
  01 Blue         constant as 01.
  01 Green        constant as 02.
  01 Cyan         constant as 03.
  01 Red          constant as 04.
  01 Magenta      constant as 05.
  01 Orange       constant as 06.
  01 Brown        constant as 06.   *> same color code as yellow
  01 LightGrey    constant as 07.   *> Light Gray

  01 Grey         constant as 08.   *> Dark Gray
  01 LightBlack   constant as 08.   *> same color code as Grey
  01 LightBlue    constant as 09.
  01 LightGreen   constant as 10.
  01 LightCyan    constant as 11.
  01 LightRed     constant as 12.
  01 LightMagenta constant as 13.
  01 Pink         constant as 13.
  01 Yellow       constant as 14.
  01 White        constant as 15.  *> white

01  AnageRec value space.
       03 AnageCodAge pic x(10) value space. *> code AGENT
       03 AnageRagSoc pic x(30) value space. *> NAME

*> Values that may be returned in CRT STATUS (or COB-CRT-STATUS)
78  K-ENTER       VALUE 0000.
78  K-UP          VALUE 2003.
78  K-DOWN        VALUE 2004.
78  K-LEFT        VALUE 2009.
78  K-RIGHT       VALUE 2010.
78  K-ESCAPE      VALUE 2005.
78  K-TAB         VALUE 2007.
78  K-BACKTAB     VALUE 2008.
78  K-PAGEUP      VALUE 2001.
78  K-PAGEDOWN    VALUE 2002.

01  wKeyPressed  PIC  9(04) VALUE 9999.
77  NumFields    pic  9(02) value 2. *> number of fields on screen

01  wBox-bco     pic 9(02) value cyan.
01  wBox-fco     pic 9(02) value black.

01 wRetCode     PIC 9999 value zero.
01 wFunc-NumVal PIC 9999 value zero.

77 Pivot    pic 9(02) value 01.
77 dbc      pic 9(04) value green. *> display backgr.color
77 dfc      pic 9(04) value white. *> display foregr.color
77 abc      pic 9(04) value 00. *> accept  backgr.color
77 afc      pic 9(04) value 15. *> accept  backgr.color
77 Pro      pic x(01) value '_'.
77 wHeader  pic x(80) value space.

01  wString   pic x(31) value space.

01 ER pic x.
   88 NoErrors value 'N'.
   88   Errors value 'Y'.

01  wCursorShow       BINARY-SHORT SIGNED value 2.
01  wCursorHide       BINARY-SHORT SIGNED value 0.

*> SAVE/RESTORE SCREEN VARIABLES
01 wScreenName        PIC X(256) value space.
01 wiScrOk            BINARY-LONG value zero.

01 Btabmess.
  03 Bmess     pic x(30) occurs 20 value space.

*> **************************************************************
*>           P R O C E D U R E   D I V I S I O N
*> **************************************************************
PROCEDURE DIVISION.
    set environment 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
    set environment 'COB_SCREEN_ESC'        TO 'Y'.
    set environment 'COB_LEGACY'            TO '1'

*> ************************************************************************************
*> D I S P L A Y    S C R E E N
*> ************************************************************************************
   string  ' SAMPLE TEST APPLICATION ' delimited by size into wHeader
   display wHeader at 0101 with  Background-Color green Foreground-Color white highlight
   display ' ESC-<Exit>                                                                     '
                   at 2501 with Background-Color green Foreground-Color white
  display ' Name ..................:' at 0501 with  Background-Color dbc Foreground-Color dfc
  display AnageRagSoc                 at 0527 with  Background-Color abc Foreground-Color afc
  display ' Code..:'                  at 0561 with  Background-Color dbc Foreground-Color dfc
  display AnageCodAge                 at 0570 with  Background-Color abc Foreground-Color afc
  continue.

LOOP-ACCEPT.
   *> re-show the cursor
   call static 'curs_set' using by value wCursorShow end-call
   go to acc01 acc02 depending on Pivot.

ACC01.
   *> NAME
   accept AnageRagSoc at 0527 with  Background-Color abc Foreground-Color afc
          update prompt character is pro auto-skip reverse-video
   go EVALUATE-KEY.
ACC02.
   *> CODE
   accept AnageCodAge at 0570 with  Background-Color abc Foreground-Color afc
          update prompt character is pro auto-skip reverse-video
   go EVALUATE-KEY.


EVALUATE-KEY.
     EVALUATE wKeyPressed
        *> ******************************************************************
        *> ENTER = CONTROLS ON SCREEN FIELDS
        *> ******************************************************************
        WHEN K-ENTER
        WHEN K-TAB
        WHEN K-DOWN
                perform CtrFields thru CtrFieldsEx
                if Errors
                   continue
                else
                   *> go to next field on screen
                   compute Pivot = Pivot + 1
                   if Pivot > NumFields move 1 to Pivot end-if
                end-if

        WHEN K-BACKTAB
        WHEN K-UP
                 perform CtrFields thru CtrFieldsEx
                 if Errors
                    continue
                 else
                    *> go to previous field on screen
                    compute Pivot = Pivot - 1
                    *> with following statement, when cursors is on 1st field
                    *> it remains there (non to go - wrap - on last filed)
                    if Pivot < 1 move 1 to Pivot end-if
                 end-if

        *> ******************************************************************
        *> ESCAPE = EXIT
        *> ******************************************************************
        when K-ESCAPE
            go to END-OF-PROGRAM

     END-EVALUATE

     GO LOOP-ACCEPT.

 *> *****************************************************************************
 *>                        E N D     O F    P R O G R A M
 *> *****************************************************************************
 END-OF-PROGRAM.
     Goback.

 *> *****************************************************************************
 *>                 C H E C K     F I E L D S   C O N T E N T
 *> *****************************************************************************
 CtrFields.
     set NoErrors to true
     go to ctr01 ctr02 depending on Pivot.
 CTR01.
     if AnageRagSoc = space
        set Errors to true
        move lightgreen to wbox-bco move white to wbox-fco
        move '111111111111111111111111111111'  to Bmess(1)
        move '        >>> ERROR 1 <<<       '  to Bmess(2)
        move '111111111111111111111111111111'  to Bmess(3)
        move '  Please Type a NAME          '  to Bmess(4)
        move '111111111111111111111111111111'  to Bmess(5)
        move '111111111111111111111111111111'  to Bmess(6)
        move '---- enter to return ---------'  to Bmess(7)
        perform DisplayErrorMessage thru DisplayErrorMessageEx
     end-if
     go CtrFieldsEx.
 CTR02.
     if AnageCodAge = space
        set Errors to true
        move lightred to wbox-bco move yellow to wbox-fco
        move '+----------------------------+'  to Bmess(1)
        move '|       >>> ERROR 2 <<<      |'  to Bmess(2)
        move '|2222222222222222222222222222|'  to Bmess(3)
        move '|     Type a CODE !!!        |'  to Bmess(4)
        move '|2222222222222222222222222222|'  to Bmess(5)
        move '|2222222222222222222222222222|'  to Bmess(6)
        move '+- Enter to return ----------+'  to Bmess(7)
        perform DisplayErrorMessage thru DisplayErrorMessageEx
     end-if
     go CtrFieldsEx.
 CtrFieldsEx. exit.

DisplayErrorMessage.
   move Z'DUMPSCREEN.TMP' to wScreenName
   call static 'scr_dump' using by reference wScreenName returning wiScrOk end-call.
   display Bmess(1) at line 04 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(2) at line 05 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(3) at line 06 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(4) at line 07 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(5) at line 08 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(6) at line 09 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   display Bmess(7) at line 10 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
   accept omitted

   call static 'scr_restore' using by reference wScreenName returning wiScrOk end-call
   call static 'refresh' returning wiScrOk end-call

      *> CALL 'CBL_DELETE_FILE' USING wScreenName
      continue.
DisplayErrorMessageEx. exit.
1 Attachments

Related

Bugs: #946

Discussion

1 2 3 > >> (Page 1 of 3)
  • Eugenio Di Lorenzo

    second screenshot

     
  • Simon Sobisch

    Simon Sobisch - 2024-02-12

    @engboris after the other one you may want to inspect this, which will possibly lead you to do debugging on screenio.c.

     
    • Boris Eng

      Boris Eng - 2024-04-02

      Sorry for the late answer, I forgot about it.

      I'm interested. You can assign it to me.

       
  • Eugenio Di Lorenzo

    Hi, I have one more clue about the nature of the bug.
    Use the following program (almost the same as the previous program, I moved the position of a field on the screen).
    The program asks for two fields to be entered.
    If you leave the first field blank then the program displays an error message on the screen and expects "enter" from the user.
    The message appears correctly the first time you leave the field blank.
    If you leave the first field blank and type "enter" more than once then the message will not appear properly from the second time onwards. The DISPLAY doesn't work !
    The DISPLAY displays only the part of the message that overlaps with the first input field !
    The same behavior happens on the second field.
    The second error message DISPLAY displays only the part of the message that overlaps with the second input field !
    I think it's a pretty serious bug!

           >>SOURCE FORMAT IS FREE
           REPLACE ==:BCOL:== BY ==with BACKGROUND-COLOR==
                   ==:FCOL:== BY ==FOREGROUND-COLOR==.
    IDENTIFICATION DIVISION.
    program-id. TESTERROR.
    
    ENVIRONMENT DIVISION.
    Configuration Section.
     SPECIAL-NAMES.
       *> CURSOR IS wCursorS
       CRT STATUS IS wKeyPressed.
    
    DATA DIVISION.
    *> **************************************************************
    WORKING-STORAGE SECTION.
    *> **************************************************************
      01 Black        constant as 00.
      01 Blue         constant as 01.
      01 Green        constant as 02.
      01 Cyan         constant as 03.
      01 Red          constant as 04.
      01 Magenta      constant as 05.
      01 Orange       constant as 06.
      01 Brown        constant as 06.   *> same color code as yellow
      01 LightGrey    constant as 07.   *> Light Gray
    
      01 Grey         constant as 08.   *> Dark Gray
      01 LightBlack   constant as 08.   *> same color code as Grey
      01 LightBlue    constant as 09.
      01 LightGreen   constant as 10.
      01 LightCyan    constant as 11.
      01 LightRed     constant as 12.
      01 LightMagenta constant as 13.
      01 Pink         constant as 13.
      01 Yellow       constant as 14.
      01 White        constant as 15.  *> white
    
    01  AnageRec value space.
           03 AnageCodAge pic x(10) value space. *> code AGENT
           03 AnageRagSoc pic x(30) value space. *> NAME
    
    *> Values that may be returned in CRT STATUS (or COB-CRT-STATUS)
    78  K-ENTER       VALUE 0000.
    78  K-UP          VALUE 2003.
    78  K-DOWN        VALUE 2004.
    78  K-LEFT        VALUE 2009.
    78  K-RIGHT       VALUE 2010.
    78  K-ESCAPE      VALUE 2005.
    78  K-TAB         VALUE 2007.
    78  K-BACKTAB     VALUE 2008.
    78  K-PAGEUP      VALUE 2001.
    78  K-PAGEDOWN    VALUE 2002.
    
    01  wKeyPressed  PIC  9(04) VALUE 9999.
    77  NumFields    pic  9(02) value 2. *> number of fields on screen
    
    01  wBox-bco     pic 9(02) value cyan.
    01  wBox-fco     pic 9(02) value black.
    
    01 wRetCode     PIC 9999 value zero.
    01 wFunc-NumVal PIC 9999 value zero.
    
    77 Pivot    pic 9(02) value 01.
    77 dbc      pic 9(04) value green. *> display backgr.color
    77 dfc      pic 9(04) value white. *> display foregr.color
    77 abc      pic 9(04) value 00.    *> accept  backgr.color
    77 afc      pic 9(04) value 15.    *> accept  backgr.color
    77 Pro      pic x(01) value '_'.
    77 wHeader  pic x(80) value space.
    
    01  wString   pic x(31) value space.
    
    01 ER pic x.
       88 NoErrors value 'N'.
       88   Errors value 'Y'.
    
    01 wCursor PIC 9(6) value zero.
    01 wCursorS PIC 9(6) value zero.
    01  wCursorShow       BINARY-SHORT SIGNED value 2.
    01  wCursorHide       BINARY-SHORT SIGNED value 0.
    
    *> SAVE/RESTORE SCREEN VARIABLES
    01 wScreenName        PIC X(256) value space.
    01 wiScrOk            BINARY-LONG value zero.
    01 wiScrOk9           PIC 9(9) value zero.
    
    01 Btabmess.
      03 Bmess     pic x(30) occurs 20 value space.
    
    *> **************************************************************
    *>           P R O C E D U R E   D I V I S I O N
    *> **************************************************************
    PROCEDURE DIVISION.
        set environment 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
        set environment 'COB_SCREEN_ESC'        TO 'Y'.
        set environment 'COB_LEGACY'            TO '1'
    
    *> ************************************************************************************
    *> D I S P L A Y    S C R E E N
    *> ************************************************************************************
       string  ' SAMPLE TEST APPLICATION ' delimited by size into wHeader
       display wHeader at 0101 with  Background-Color green Foreground-Color white highlight
       display ' ESC-<Exit>                                                                     '
                       at 2501 with Background-Color green Foreground-Color white
      display ' Name ..................:' at 0501 with  Background-Color dbc Foreground-Color dfc
      display AnageRagSoc                 at 0527 with  Background-Color abc Foreground-Color afc
      display ' Code...................:' at 0701 with  Background-Color dbc Foreground-Color dfc
      display AnageCodAge                 at 0727 with  Background-Color abc Foreground-Color afc
      continue.
    
    LOOP-ACCEPT.
       *> re-show the cursor
       *> call static 'curs_set' using by value wCursorShow end-call
       go to acc01 acc02 depending on Pivot.
    
    ACC01.
       *> NAME
       move 005039 to wCursorS
       accept AnageRagSoc at 0527 with  Background-Color abc Foreground-Color afc
              update prompt character is pro auto-skip reverse-video cursor wCursor end-accept
       go EVALUATE-KEY.
    ACC02.
       *> CODE
       accept AnageCodAge at 0727 with  Background-Color abc Foreground-Color afc
              update prompt character is pro auto-skip reverse-video cursor wCursor end-accept
       go EVALUATE-KEY.
    
    
    EVALUATE-KEY.
         EVALUATE wKeyPressed
            *> ******************************************************************
            *> ENTER = CONTROLS ON SCREEN FIELDS
            *> ******************************************************************
            WHEN K-ENTER
            WHEN K-TAB
            WHEN K-DOWN
                    perform CtrFields thru CtrFieldsEx
                    if Errors
                       continue
                    else
                       *> go to next field on screen
                       compute Pivot = Pivot + 1
                       if Pivot > NumFields move 1 to Pivot end-if
                    end-if
    
            WHEN K-BACKTAB
            WHEN K-UP
                     perform CtrFields thru CtrFieldsEx
                     if Errors
                        continue
                     else
                        *> go to previous field on screen
                        compute Pivot = Pivot - 1
                        *> with following statement, when cursors is on 1st field
                        *> it remains there (non to go - wrap - on last filed)
                        if Pivot < 1 move 1 to Pivot end-if
                     end-if
    
            *> ******************************************************************
            *> ESCAPE = EXIT
            *> ******************************************************************
            when K-ESCAPE
                go to END-OF-PROGRAM
    
         END-EVALUATE
    
         GO LOOP-ACCEPT.
    
     *> *****************************************************************************
     *>                        E N D     O F    P R O G R A M
     *> *****************************************************************************
     END-OF-PROGRAM.
         STOP RUN.
    
     *> *****************************************************************************
     *>                 C H E C K     F I E L D S   C O N T E N T
     *> *****************************************************************************
     CtrFields.
         set NoErrors to true
         go to ctr01 ctr02 depending on Pivot.
     CTR01.
         if AnageRagSoc = space
            set Errors to true
            move lightgreen to wbox-bco move white to wbox-fco
            move '111111111111111111111111111111'  to Bmess(1)
            move '>>>>>>>>>>> ERROR 1 <<<<<<<<<<'  to Bmess(2)
            move '111111111111111111111111111111'  to Bmess(3)
            move '  Please Type a NAME          '  to Bmess(4)
            move '111111111111111111111111111111'  to Bmess(5)
            move '111111111111111111111111111111'  to Bmess(6)
            move '---- enter to return ---------'  to Bmess(7)
            perform DisplayErrorMessage thru DisplayErrorMessageEx
         end-if
         go CtrFieldsEx.
     CTR02.
         if AnageCodAge = space
            set Errors to true
            move lightred to wbox-bco move yellow to wbox-fco
            move '+----------------------------+'  to Bmess(1)
            move '|       >>> ERROR 2 <<<      |'  to Bmess(2)
            move '|2222222222222222222222222222|'  to Bmess(3)
            move '|     Type a CODE !!!!!!!!!!!|'  to Bmess(4)
            move '|2222222222222222222222222222|'  to Bmess(5)
            move '|2222222222222222222222222222|'  to Bmess(6)
            move '+- Enter to return ----------+'  to Bmess(7)
            perform DisplayErrorMessage thru DisplayErrorMessageEx
         end-if
         go CtrFieldsEx.
     CtrFieldsEx. exit.
    
    DisplayErrorMessage.
      *> save the screen before message
       move Z'DUMPSCREEN.TMP' to wScreenName
       call static 'scr_dump' using by reference wScreenName returning wiScrOk end-call 
    
      *> *************************************************************************
      *> display the error message
      *> this display works fine only first time !! 
      *> *************************************************************************
       display Bmess(1) at line 04 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(2) at line 05 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(3) at line 06 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(4) at line 07 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(5) at line 08 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(6) at line 09 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(7) at line 10 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       accept omitted
    
      *> restore the screen after message is read by the user
       call static 'scr_restore' using by reference wScreenName returning wiScrOk end-call
       call static 'refresh' returning wiScrOk end-call
       CALL 'CBL_DELETE_FILE' USING wScreenName
       continue.
    DisplayErrorMessageEx. exit.
    

    ERR310 320 and 330 are screenshot for first field
    ERR 410 420 and 430 are screenshot for second filed

     
  • Simon Sobisch

    Simon Sobisch - 2024-04-02
    • labels: --> screenio, libcob
    • status: open --> pending
    • assigned_to: Boris Eng
     
  • Eugenio Di Lorenzo

    Hi, this bug is very disturbing in the development of TUI interfaces.
    Are there any updates and hopes for its resolution?

     
    • Boris Eng

      Boris Eng - 2024-05-21

      Hello. I will investigate it very soon.

       
      • Eugenio Di Lorenzo

        thank you very much from me too.
        Please feel free to contact me with anything I can contribute.

         
        • Boris Eng

          Boris Eng - 2024-05-22

          I am sorry for the delay although I accepted to be assigned to this bug.

          I recommend to put the command line you use to compile for bug reports. I tried to execute your code but did not exactly obtain the same behaviour as you: both programs exit with attempt to reference unallocated memory (signal SIGSEGV) after typing ENTER two times.

          After a first glance, it looks like it is an error related to memory and more precisely to the call static 'scr_dump' and call static 'src_restore' statements at the end.

          I will dig into it more later but what could help is to provide a minimal example where this bug occurs. Something as simple as possible.

           
          • Vincent (Bryan) Coen

            Did you run this under Linux ?

            Vince

             

            Last edit: Simon Sobisch 2024-06-07
            • Boris Eng

              Boris Eng - 2024-05-22

              Yes, I did.

              If this is of any importance, I'm a new contributor but I can still give this bug a try. However, if there is somebody willing to do it, it may accelerate the bug fix.

               
              • Vincent (Bryan) Coen

                I use one  of these calls on more than one program but do NOT use STATIC i.e.,

                  CA300-Save-Screen.
                      move     z"flg-temp.scr"  to wScreenName.
                      call     "scr_dump"    using wScreenName returning wInt.
                *>
                  CA301-Restore-Screen.
                      call     "scr_restore" using wScreenName returning wInt.
                      call     "CBL_DELETE_FILE" using "flg-temp.scr".
                

                Used to save a copy of current screen then restore it after completing another process that display to screen, etc.

                No Idea if STATIC might be the cause but possibly worth a try.

                 

                Last edit: Simon Sobisch 2024-06-07
  • Eugenio Di Lorenzo

    I have further simplified the program.
    It must be compiled and executed without parameters
    My compilation from OpenCobolIDE is as follows

    C:\OpenCobolIDE\GC20base2\bin\cobc.exe -x -o bin\TESTERROR.exe -std=default -debug -fdebugging-line -ftrace -free -lpdcurses TESTERROR.COB

    At first ACCEPT press ENTER without typing anything
    The program shows an error message (asks you to type something in the field)
    You type ENTER after reading the message and the program performs the ACCEPT again
    Press ENTER again without typing anything in th efield at screen
    The program should show the same error message but the DISPLAY statement does not work and displays nothing !!!

    I have done step by step debugging of this program with COBGDB but don't see anything different.
    The DISPLAY statement works well the first time, the subsequent times (after the SCREEN RESTORE) it no longer works well.

           >>SOURCE FORMAT IS FREE
           REPLACE ==:BCOL:== BY ==with BACKGROUND-COLOR==
                   ==:FCOL:== BY ==FOREGROUND-COLOR==.
    IDENTIFICATION DIVISION.
    program-id. TESTERROR.
    
    ENVIRONMENT DIVISION.
    Configuration Section.
     SPECIAL-NAMES.
       CRT STATUS IS wKeyPressed.
    
    DATA DIVISION.
    WORKING-STORAGE SECTION.
      01 Black        constant as 00.
      01 Green        constant as 02.
      01 Cyan         constant as 03.
      01 LightGreen   constant as 10.
      01 LightRed     constant as 12.
      01 Yellow       constant as 14.
      01 White        constant as 15.  
    
    01 AnageCodAge pic x(10) value space. *> code AGENT
    01 AnageRagSoc pic x(30) value space. *> NAME
    
    78  K-ENTER       VALUE 0000.
    78  K-ESCAPE      VALUE 2005.
    77  wKeyPressed  PIC  9(04) VALUE 9999.
    77  NumFields    pic  9(02) value 2. *> number of fields on screen
    
    01  wBox-bco     pic 9(02) value cyan.
    01  wBox-fco     pic 9(02) value black.
    
    77 Pivot    pic 9(02) value 01.
    77 dbc      pic 9(04) value green. *> display backgr.color
    77 dfc      pic 9(04) value white. *> display foregr.color
    77 abc      pic 9(04) value 00.    *> accept  backgr.color
    77 afc      pic 9(04) value 15.    *> accept  backgr.color
    77 wHeader  pic x(80) value space.
    01  wString pic x(31) value space.
    01 ER pic x.
       88 NoErrors value 'N'.
       88   Errors value 'Y'.
    
    *> SAVE/RESTORE SCREEN VARIABLES
    01 wScreenName        PIC X(256) value space.
    01 wiScrOk            BINARY-LONG value zero.
    01 wiScrOk9           PIC 9(9) value zero.
    
    01 Btabmess.
      03 Bmess     pic x(30) occurs 20 value space.
    
    *> **************************************************************
    *>           P R O C E D U R E   D I V I S I O N
    *> **************************************************************
    PROCEDURE DIVISION.
        set environment 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
        set environment 'COB_SCREEN_ESC'        TO 'Y'.
        set environment 'COB_LEGACY'            TO '1'
    
    *> *******************************************************************
    *> D I S P L A Y    S C R E E N
    *> *******************************************************************
       string  ' SAMPLE TEST APPLICATION ' delimited by size into wHeader
       display wHeader at 0101 with  Background-Color green Foreground-Color white highlight
       display ' ESC-<Exit>                                                                     '
                       at 2501 with Background-Color green Foreground-Color white
      display ' Name ..................:' at 0501 with  Background-Color dbc Foreground-Color dfc
      display AnageRagSoc                 at 0527 with  Background-Color abc Foreground-Color afc
      display ' Code...................:' at 0701 with  Background-Color dbc Foreground-Color dfc
      display AnageCodAge                 at 0727 with  Background-Color abc Foreground-Color afc
      continue.
    
    LOOP-ACCEPT.
       go to acc01 acc02 depending on Pivot.
    
    ACC01.
       accept AnageRagSoc at 0527 with  Background-Color abc Foreground-Color afc
              update prompt '_' auto-skip reverse-video  
       go EVALUATE-KEY.
    ACC02.
       accept AnageCodAge at 0727 with  Background-Color abc Foreground-Color afc
              update prompt '_' auto-skip reverse-video  
       go EVALUATE-KEY.
    
    
    EVALUATE-KEY.
         EVALUATE wKeyPressed
    
            WHEN K-ENTER
                    perform CtrFields thru CtrFieldsEx
                    if Errors
                       continue
                    else
                       *> go to next field on screen
                       compute Pivot = Pivot + 1
                       if Pivot > NumFields move 1 to Pivot end-if
                    end-if
    
            when K-ESCAPE
                go to END-OF-PROGRAM
    
         END-EVALUATE
         GO LOOP-ACCEPT.
    
     END-OF-PROGRAM.
         STOP RUN.
    
    
    
    
    
     *> **********************************************************************
     *>                 C H E C K     F I E L D S   C O N T E N T
     *> **********************************************************************
     CtrFields.
         set NoErrors to true
         go to ctr01 ctr02 depending on Pivot.
     CTR01.
         if AnageRagSoc = space
            set Errors to true
            move lightgreen to wbox-bco move white to wbox-fco
            move '111111111111111111111111111111'  to Bmess(1)
            move '>>>>>>>>>>> ERROR 1 <<<<<<<<<<'  to Bmess(2)
            move '111111111111111111111111111111'  to Bmess(3)
            move '  Please Type a NAME          '  to Bmess(4)
            move '111111111111111111111111111111'  to Bmess(5)
            move '111111111111111111111111111111'  to Bmess(6)
            move '---- enter to return ---------'  to Bmess(7)
            perform DisplayErrorMessage thru DisplayErrorMessageEx
         end-if
         go CtrFieldsEx.
     CTR02.
         if AnageCodAge = space
            set Errors to true
            move lightred to wbox-bco move yellow to wbox-fco
            move '+----------------------------+'  to Bmess(1)
            move '|       >>> ERROR 2 <<<      |'  to Bmess(2)
            move '|2222222222222222222222222222|'  to Bmess(3)
            move '|     Type a CODE !!!!!!!!!!!|'  to Bmess(4)
            move '|2222222222222222222222222222|'  to Bmess(5)
            move '|2222222222222222222222222222|'  to Bmess(6)
            move '+- Enter to return ----------+'  to Bmess(7)
            perform DisplayErrorMessage thru DisplayErrorMessageEx
         end-if
         go CtrFieldsEx.
     CtrFieldsEx. exit.
    
    DisplayErrorMessage.
      *> save the screen before message
       move Z'DUMPSCREEN.TMP' to wScreenName
       call  static 'scr_dump' using by reference wScreenName returning wiScrOk end-call
    
      *> *************************************************************************
      *> display the error message in a BOX 
    
    
      *> these displays works fine only first time !!!
      *> THEY DOES NOT WORK AFTER A SCREEN RESTORE !!! 
      *> THEY DOES NOT WORK AFTER A SCREEN RESTORE !!!
      *> THEY DOES NOT WORK AFTER A SCREEN RESTORE !!!
    
      *> *************************************************************************
       display Bmess(1) at line 04 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(2) at line 05 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(3) at line 06 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(4) at line 07 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(5) at line 08 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(6) at line 09 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       display Bmess(7) at line 10 col 10 :BCOL: wbox-bco :FCOL: wbox-fco
       accept omitted
    
      *> restore the screen after ACCEPT OMITTED (the message is read by the user an duser press ENTER)
      *> the RESTORE WORKS FINE !
       call  static 'scr_restore' using by reference wScreenName returning wiScrOk end-call
       call static 'refresh' returning wiScrOk end-call
       CALL 'CBL_DELETE_FILE' USING wScreenName
       continue.
    DisplayErrorMessageEx. exit.
    
     
  • Boris Eng

    Boris Eng - 2024-05-28

    Hello @sf-mensch. After some thought, I believe it is wiser to remove my assignment to this bug as I am unfortunately being busy with other tasks and cannot guarantee I will be able to look at it soon. Sorry for the inconvenience.

     
  • Eugenio Di Lorenzo

    Hi Simon, I have the impression that this bug, quite complex to describe, is not so simple to investigate, much less simple to solve.
    This is a very bad anomaly, in my opinion.
    For these reasons I believe that your direct intervention would be very desirable and important.

     
    • Simon Sobisch

      Simon Sobisch - 2024-06-04

      I think the minimal example doesn't need the curs_set() call - then drop it.

      Then the error only happens when you use - outside of GnuCOBOL's
      screenio - the scr_dump/scr_restore/refresh functions, right?

       
  • Eugenio Di Lorenzo

    there is no curs_set() call in the source sample of my last post 2024-05-23.
    The error happens becouse I need to save the screen, display an errore message and restore the screen previuos the error message.
    There is no alternative so i have to use scr_dump to save the screen and scr_restore to restore the screen.

     

    Last edit: Eugenio Di Lorenzo 2024-06-04
    • Simon Sobisch

      Simon Sobisch - 2024-06-04

      Maybe chuck can inspect this if it only happens with these calls - but
      in general it seems more appropriate to create CBL functions for these
      functions

      Note per
      https://github.com/Bill-Gray/PDCursesMod/blob/master/docs/MANUAL.md#scr_dump
      the functions putwin() and getwin() would be preferable; but they do
      something different as soon as we support multiple windows.

      Note: from the COBOL programmer view the best would be to use DISPLAY
      WINDOW and friends, but these are not implemented yet (patches welcome
      and I think relative easy) and would only be portable to GnuCOBOL,
      ACUCOBOL, possibly RM/COBOL and MF COBOL.

      Simon

       
  • Eugenio Di Lorenzo

    The two functions that should be implemented are the following
    CBL_READ_SCR_CHATTRS
    CBL_WRITE_SCR_CHATTRS
    which save in the COBOL program memory and write from the COBOL program memory a rectangular portion (like a window) of the screen with the characters and attributes (color, highlight ...)
    But this is another thing that has already been discussed for a long time in this forum without finding a solution.
    Chuck has already created some similar functions but they are not compatible with pdcurses :-(

    For now it would be useful if the bug (DISPLAY not working) could be solved.

     
  • Chuck H.

    Chuck H. - 2024-06-05

    Eugenio,

    I i think that a solution would be the addition of two cbl functions to be added to libcob. one to save the screen and the other to restore.. The reason I would prefer this approach is that once you start calling curses functions directly from COBOL, the COBOL programmer would be responsible for any issues in that there is no way the screenio portion of the compiler runtime could ensure that the CURSES functionality is correct. So I think that it would be best to do this with new CBL functions within the compiler itself.

    it would determine the screen size ... lines / columns / chtype size and allocate a buffer to store the screen data. Also save the screen size and cursor position. If the current screen size is not the same as the saved size the restore would fail.

    i'm not sure what scr_save / scr_restore are doing under the covers and the above method would eliminate that.

    I have used this technique or something very similar in my C screen painter program. it should not be too difficult to do.

    l would want to get a consensus on the functionality of these before investing my time on them
    so there is an agreement on the scope and deliverables.

    The testing of this would be simplified as the development / testing could be done with an external C program. After approval of the testing results it could easily be incorporated into the libcob runtime.

    please provide your feedback on this approach.

    Chuck Haatvedt
    
     
    • Simon Sobisch

      Simon Sobisch - 2024-06-05

      I am sure there must be functions in MicroFocus/ACUCOBOL to do that. For easing migrations and for pre-set of the rules and possible examples this would be preferable to create an own function.

       
  • Eugenio Di Lorenzo

    Hi Chuck, personally I don't think your proposal of doing without the pdcurses library functions is a good solution. The entire architecture of GnuCOBOL (e.g. all ACCEPT and all DISPLAY) has been set on this library.

    As I said in my previous post, the two functions that read and write characters and attributes on the screen already present in other compilers (Realia, Mricofocus ...) such as READ_SCR_CHATTRS and WRITE_SCR_CHATTRS are one of the main gaps that still remain in GnuCOBOL.

    I had already raised the issue at his time (2016). please see:
    https://sourceforge.net/p/gnucobol/discussion/help/thread/4a975c9b/?limit=50#32dd/5a31/df1c/3ca4/b9a9/505b/c8d9/6b10/6dbc

    See also
    https://sourceforge.net/p/gnucobol/discussion/contrib/thread/f5934f0f/?limit=50#fd9f

    and
    https://sourceforge.net/p/gnucobol/discussion/help/thread/c5345903/?limit=50#4c62/feb8/b2de/217e

    The solution of using the pdcurses scr_dump and scr_restore functions is currently the only working option.
    Over time, the bug I had already reported emerged. Marcos Martin Duma, the author of COBGDB, also reported the same bug in the same post.
    Then I tried using calls to the pdcurses mvinch() function which reads characters and attributes from the screen. see GnuCOBOL source example in the same post.

    Now we are talking about two goals.
    1. Fix the bug described here. When using scr_dump and then scr_restore in the case described, the DISPLAY statement no longer works! With this solution we will also be able to do without the two functions referred to in the following point.
    2. create the two new CBL functions CBL_READ_SCR_CHATTRS and CBL_WRITE_SCR_CHATTRS which would give greater compatibility with other compilers.
    The bug referred to in the previous point should still be resolved.

    For me at the moment it is appropriate to give priority to fixing the bug.
    The DISPLAY statement does not work correctly and this bug needs to be fixed i thik ASAP.

     

    Last edit: Eugenio Di Lorenzo 2024-06-05
    • Simon Sobisch

      Simon Sobisch - 2024-06-05

      personally I don't think your proposal of doing without the pdcurses library functions is a good solution. The entire architecture of GnuCOBOL (e.g. all ACCEPT and all DISPLAY) has been set on this library.

      The point is to call those curses functions from within
      libcob/screenio.c, instead of from a COBOL program.

       
  • Chuck H.

    Chuck H. - 2024-06-06

    Eugenio,

    we have confirmed that this is the result of a bug in PDCURSES_MOD. Your test program works as expected in Linux which uses NCURSES. We have communicated the issue to the author / maintainer of PDCURSES_MOD and will update this report as we learn more from Bill Gray , the maintainer of PDCURSES_MOD.

    Simon may have a windows build with NCURSES. If it is urgent and you can't wait for the pdcurses fix, I could attempt to build GNUCOBOL with NCURSES on Windows. I'm busy working on restaining my deck for the next week or so depending on the weather so I may not have time for this until after that is finished.

              Chuck Haatvedt
    
     
    • Simon Sobisch

      Simon Sobisch - 2024-06-06

      Note: the default binaries on MSYS2 are all ncursesw based

       
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.