#35 Screen Section Bug - OCCURS clause

GC 3.x
accepted
nobody
5 - default
7 days ago
2012-02-23
DarkSetz
No

The OCCURS verb's use in the Screen Section is recognized as correct by the compiler but it is not acted upon at run-time.

A DISPLAY statement of following code produces a window that looks like this:

+------------------------------+
|                              |
+------------------------------+

when it should produce one with ten lines of body between the top and bottom borders instead of just one.

    01  OffD-Maint-Scrn-Skills-SMenu    FOREGROUND-COLOR COLOR-WHITE.
        05  LINE Window-UpperLeft-Corner-Line   COL Window-UpperLeft-Corner-Column  VALUE "+".
        05  PIC X(30)   FROM Dashed-Line.
        05  VALUE "+".
        05  OffD-MSSSM-Body OCCURS 10 TIMES.
            10  LINE PLUS 1 COL Window-UpperLeft-Corner-Column  VALUE "|".
            10  PIC X(30)   FROM Blank-Line.
            10  VALUE "|".
        05  LINE PLUS 1 COL Window-UpperLeft-Corner-Column  VALUE "+".
        05  PIC X(30)   FROM Dashed-Line.
        05  VALUE "+".
1 Attachments

Related

Bugs: #248
Bugs: #347
Bugs: #430
Discussion: In search of a project
Discussion: error in screen section occurs clause.
Discussion: occurs in screen section

Discussion

  • Vincent (Bryan) Coen

    Error still present in v1.1 March 12, 2010

     
  • Simon Sobisch

    Simon Sobisch - 2014-02-26

    Rechecked with GNU Cobol 1.1 release (scrocc.cbl attached), problem still exists.
    With 2.x there is only one instead of 10 lines, too and additional the first "|" in the line is missing.

    Simon

     
    • Vincent (Bryan) Coen

      An issue that was similar if not the same was reported to Roger two
      +years ago by myself against a test program in the lists.
      It also involved occurs & values within screen section.

      I tested it after a fix (by Roger) to confirm it was resolved.
      I am a little puzzled why this has re-appeared, so assume that the v2
      code base is not of the latest that Roger had given out to us for
      testing and no it was not the first release !

      Looks like I must browse the code base between the original and v2.1.

      Before I do so please confirm what version it has been tested against.

      Vince

       
      Last edit: Simon Sobisch 2014-08-05
  • Simon Sobisch

    Simon Sobisch - 2014-08-05

    Still broken with current svn revision in 2.x.

    Here is another sample that doesn't work:

           IDENTIFICATION DIVISION.
           PROGRAM-ID. prog.
    
           SCREEN SECTION.
           01  screen-var LINE 1.
               03  nums COL PLUS 3 PIC 999 OCCURS 3 TIMES.
    
           PROCEDURE DIVISION.
               DISPLAY screen-var END-DISPLAY.
               ACCEPT  omitted    END-ACCEPT.
               STOP RUN.
    

    Simon

     
  • Louis Krupp

    Louis Krupp - 2014-09-05

    Potential patch for groups and fields with OCCURS clause.

     
  • Edward Hart

    Edward Hart - 2016-06-08
    • labels: --> screen section, OCCURS
    • summary: Screen Section Bug - OCCURS verb --> Screen Section Bug - OCCURS clause
    • status: open --> accepted
    • Group: unclassified --> GC 2.0
    • Priority: 5 --> 5 - default
     
  • Edward Hart

    Edward Hart - 2016-06-08
    • assigned_to: Edward Hart
     
  • Simon Sobisch

    Simon Sobisch - 2016-10-12

    Edward, can you please check the patch and commit the fix and upload your updated screenio tests?

     
    • Edward Hart

      Edward Hart - 2016-10-12

      I can't clearly recall reviewing that patch, but I think it failed to account for how screen fields were allocated. I'll check it more thoroughly again, though.

      I had a go myself a few months back. I found two possible approaches:

      • Adding a pointer parameter to the screen functions in libcob to handle arrays. I never did this, because it I didn't have the energy to modify a lot of typeck.c and to change the algorithm used in iterating over screen fields.
      • Treating each table entry as a new field. This meant less change and easier support for higher-dimensioned tables, but at the cost of massive bloat in generated code. I attempted to implement this, but eventually gave up.
       
      Last edit: Edward Hart 2016-10-17
  • Edward Hart

    Edward Hart - 2016-10-17
    • assigned_to: Edward Hart --> nobody
     
  • Edward Hart

    Edward Hart - 2016-10-17

    Louis' patch fails when provided with

           *> ...
           DATA DIVISION.
           SCREEN SECTION.
           01  scr.
               03  scr-table COL + 1 PIC X OCCURS 10 TIMES VALUE "b".
    
           PROCEDURE DIVISION.
               DISPLAY scr AT LINE 1, COL 1 *> Only displays one b at COL 2.
               *> ...
    

    and causes compilation errors when you try to display just one element of a table (specifically, the compiler tries to pass a cob_field * to a function expecting a cob_screen *).

    As such, this bug requires a non-trivial patch to fix. As I now lack the time (and interest) to provide that, I'm removing myself as the owner of this ticket.

     
  • PatMcC

    PatMcC - 2017-06-18

    Hi Edward

    I am going to need a lot of time to get this done but I am interested in fixing this.

    I think this feature has value for adding boxes and lines and such.

    -Pat

     
    • Louis Krupp

      Louis Krupp - 2017-06-21

      I looked at this a couple of years ago. I had a patch (see attached)
      that fixed at least part of the problem at the time, but intervening
      changes to screenio.c have made it pretty useless now. When Edward got
      back to me last October, I said I'd look at it, but I got distracted by
      other things.

      The problem seems to be that cob_screen_puts() calls
      get_screen_item_line_and_col() to return the static line and column
      associated with an item, and those are assigned to cob_current_y and
      cob_current_x. This overrides the line increment that happens in
      cob_screen_moveyx(), so the displayed box is still flat.

      Good luck with this.

      Louis

       
      Last edit: Simon Sobisch 2017-06-21
  • Simon Sobisch

    Simon Sobisch - 2017-07-03

    Note for anyone checking this issue: we have an additional parsing part to do here as the relative line/col checks are currently done directly on the field, but it should likely be postponed until all childs are parsed as the program above may be coded (at least with ACUCOBOL) as

           IDENTIFICATION DIVISION.
           PROGRAM-ID. prog.
    
           SCREEN SECTION.
           01  screen-var LINE 1.
               03  FILLER OCCURS 3 TIMES.
                   05  nums COL PLUS 3 PIC 999.
    
           PROCEDURE DIVISION.
               DISPLAY screen-var END-DISPLAY.
               ACCEPT  omitted    END-ACCEPT.
               STOP RUN.
    

    which in this case results in error: relative LINE/COLUMN clause required with OCCURS. It compiles if the relative position is moved next to the OCCURS clause, but should work with the sample above, too.

    And another part is references to a table:

           IDENTIFICATION DIVISION.
           PROGRAM-ID. prog.
    
           01  DATA-TAB.
               03 DATA-LINE OCCURS 3.
                   05 nums COL PIC 999.
    
           SCREEN SECTION.
           01  screen-var LINE 1.
               03  FILLER OCCURS 3 TIMES COL PLUS 3.
                   05 COL 07 PIC zz9 FROM nums.
    
           PROCEDURE DIVISION.
               DISPLAY screen-var END-DISPLAY.
               ACCEPT  omitted    END-ACCEPT.
               STOP RUN.
    

    Not sure if the rule is "anything referenced with USING/FROM below the OCCURS must be a table item with at least the same size" or "if it is a table item it the same index is used, otherwise no index"...

     
  • Simon Sobisch

    Simon Sobisch - 2017-08-18
    • Group: 2.2 --> GC 2.3
     
  • Simon Sobisch

    Simon Sobisch - 2017-08-18

    Should raise a PENDING("OCCURS in SCREEN SECTION") as the runtime doesn't handle it.

     
    • Edward Hart

      Edward Hart - 2017-08-18

      Done in [r1999].

       

      Related

      Commit: [r1999]

      • Simon Sobisch

        Simon Sobisch - 2017-08-18

        Thank you, nothing more to do here for 2.2.

         
  • Simon Sobisch

    Simon Sobisch - 7 days ago
    • Group: GC 3.0 --> GC 3.x
     

Log in to post a comment.