Hello David,
your request is very legal.
Counting the data before calling DISPLAY ARRAY is annoying (and costs
resources).
I clearly point out: the ON FILL BUFFER feature was introduced to use
any number of rows in the DISPLAY ARRAY instruction.
I would like to implement your request by setting the arr_count to -1.
What's the idea: until the real array size is unknown, we guess the size to
be one page greater then the maximum row-index we ever used.
See this really working example (notice 2.10 is required. You must set
the environment variable FGL_USENDIALOG to use the new multiple dialog
implementation in traditional DISPLAY ARRAY).
This is similar what you can obtain when testing queries in SQL server,
they have the same growing scrollbar.
Rene
--this file: fill_buffer.4gl
DATABASE stores
MAIN
DEFINE a DYNAMIC ARRAY OF LIKE systables.tabname
DEFINE l, s, i, guessed_count, real_count, max_row, page_size INT
OPEN FORM f FROM "fill_buffer"
DISPLAY FORM f
LET page_size = 5
LET max_row = 0
LET guessed_count = page_size
LET real_count = NULL
CALL set_count(guessed_count)
DECLARE cu SCROLL CURSOR FOR
SELECT tabname FROM systables
OPEN cu
DISPLAY ARRAY a TO r.*
ON FILL BUFFER
CALL a.CLEAR()
LET s = fgl_dialog_getbufferStart()
LET l = fgl_dialog_getbufferLength()
IF real_count IS NULL THEN
DISPLAY "on fill buffer:", s, s + l - 1, guessed_count
END IF
FOR i = 1 TO l
FETCH ABSOLUTE s cu INTO a
IF status == NOTFOUND AND real_count IS NULL THEN
LET real_count = s - 1
DISPLAY "setArrayLength - finally: ", real_count
CALL DIALOG.setArrayLength("r", real_count)
CONTINUE DISPLAY
END IF
LET s = s + 1
END FOR
-- next block is not required if the runtime supports
-- ON FILL BUFFER and unknown arr_count.
IF real_count IS NULL AND s - 1 > max_row THEN
-- We have been asked for a row we've never seen
LET max_row = s - 1
DISPLAY "max_row:", max_row
-- guess we have more rows...
LET guessed_count = max_row + page_size
CALL DIALOG.setArrayLength("r", guessed_count)
DISPLAY "setArrayLength - guessed: ", guessed_count
END IF
END DISPLAY
END MAIN
--this file: fill_buffer.per
LAYOUT
GRID
{
<t t1 >
array
[a1 ]
[a1 ]
[a1 ]
[a1 ]
[a1 ]
}
END
END
ATTRIBUTES
a1=FORMONLY.a1;
INSTRUCTIONS
SCREEN RECORD r(a1);