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 "+".
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: Screen anomaly???
Patches: #41
Error still present in v1.1 March 12, 2010
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
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
Still broken with current svn revision in 2.x.
Here is another sample that doesn't work:
Simon
Potential patch for groups and fields with OCCURS clause.
Edward, can you please check the patch and commit the fix and upload your updated screenio tests?
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:
Last edit: Edward Hart 2016-10-17
Louis' patch fails when provided with
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 acob_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.
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
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
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
which in this case results in
error: relative LINE/COLUMN clause required with OCCURS
. It compiles if the relative position is moved next to theOCCURS
clause, but should work with the sample above, too.And another part is references to a table:
Not sure if the rule is "anything referenced with
USING
/FROM
below theOCCURS
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"...Should raise a
PENDING("OCCURS in SCREEN SECTION")
as the runtime doesn't handle it.Done in [r1999].
Thank you, nothing more to do here for 2.2.
Hi, all!
What is the next steps with this "problem"? I'm trying to migrate a lot of programs from mfcobol to opencobol, and, it's a hard work to convert tables in screen section to non-tables fields. Is there a practical workaround?
Hi Jorge
I don't know of a work around but I will give this bug a try over the holiday break. maybe I can figure it out.
-Pat
Thank you, Patrick!
Please, let me know any news about it.
And if I can collaborate, gladly
jorge
Hi Guys
I haven't been so great for a few months but I am pretty sick right now, I think it's the flu. Sorry if this is another low quality post :(
I inserted fprintf statements in all of the functions in screenio. In cob_prep_input, I have this as well:
and there is one at the start of cob_prep_input that prints the value of s->occurs.
Here is the output of the fprintf statements. I need to looks at this when I am feeling better but I am wondering if the occurs member in the linked list of cob_screens is not being processed in the right order. It's a linked list and if it is looped through already, there is nothing left to process. I am still not sure...
The cob_addnstr may be a bit misleading as the fprintf statement is not NUL terminated. However it is still also the only time it was printed to the screen
Here is the output of the fprintf statements
cob_screen_accept
extract_line_and_col_vals
screen_accept
init_cob_screen_if_needed
cob_screen_init
cob_move_cursor
cob_prep_input
pausing at start of cob_prep_input, occurs is 0
cob_screen_moveyx
cob_move_cursor
cob_prep_input
pausing at start of cob_prep_input, occurs is 0
cob_screen_puts
get_screen_item_line_and_col
is_first_screen_item
get_prev_screen_item
get_prev_screen_item
cob_move_cursor
cob_screen_attr
cob_addnstr
raise_ec_on_truncation
adding str in cob_addnstr(and getch) occurs screen thing 1 thing 1 thing 1 thing 1 , size is 20
cob_prep_input
pausing at start of cob_prep_input, occurs is 17
cob_screen_moveyx
cob_move_cursor
cob_prep_input
pausing at start of cob_prep_input, occurs is 0
cob_screen_puts
get_screen_item_line_and_col
get_prev_screen_item
get_prev_screen_item
get_prev_screen_item
get_prev_screen_item
cob_move_cursor
cob_screen_attr
Hi Everyone
Still sick and brain dead here but still trying.
See these fprintf statemetns:
cob_prep_input
pausing at start of cob_prep_input, occurs is 17
address of cob_screen is is 0x6022e0
case TYPE_FIELD (TAKE NOTE OF THIS)
cob_screen_puts
get_screen_item_line_and_col
get_prev_screen_item
get_prev_screen_item
cob_move_cursor
cob_screen_attr
raise_ec_on_truncation
cob_addch_no_trunc_check
--Here is the part where thing-1 is added 1 char by char
addch in cob_addch(and getch) t cob_addch_no_trunc_check
addch in cob_addch(and getch) h cob_addch_no_trunc_check
addch in cob_addch(and getch) i cob_addch_no_trunc_check
addch in cob_addch(and getch) n cob_addch_no_trunc_check
addch in cob_addch(and getch) g cob_addch_no_trunc_check
addch in cob_addch(and getch) _ cob_addch_no_trunc_check
addch in cob_addch(and getch) 1 cob_addch_no_trunc_check
addch in cob_addch(and getch) _ cob_addch_no_trunc_check
addch in cob_addch(and getch) _ cob_addch_no_trunc_check
But look at this code
The code to generate the occurs is in the case: COB_SCREEN_TYPE_VALUE
which is never reached
I also changed my test program:
I think there are many problems with this screenio occurs code. I changed my COBOL test program because I can't see how multiple 05 subordinates would be drawn to the screen in it's current state.
Does anyone know of a revision where the screenio occurs code actually worked?
Last edit: Patrick McCavery 2018-12-31
Yes and no.
Roger sent me a note, this would be in the eight years ago range, when OCCURS first went into OpenCOBOL. That was, sadly, too many hardrives, web hosts, email providers to even guess at a date range to look at any old archives of opencobol prerel tarballs that someone might have stashed.
I wrote a quick trial, it passed. And that's about all I can say, Patrick. I know that OpenCOBOL has properly handled SCREEN OCCURS, but the fog of brain doesn't have enough electronic threads at the moment to track down the conversations.
We don't have access to the actual code repository that was in use at the time, as far as I'm aware. We got post checkout and autotool'ed tarballs back then.
Sorry for being so nebulous. It has worked, but if it doesn't in rev 1 of the svn copies here, I'm not sure you can go back further without tracking down 8ish year old copies of the opencobol prerel tarballs.
Blue