Page 1 of 1
issue-#50 unlimited number of columns in SqlControls.Control
Posted: Thu May 21, 2015 11:52 am
by Josef Templ
The table control in SqlControl.Control has a hard wired limit of 40 columns in BB 1.6.
For serious work this is way too small. Therefore the limit is removed in this issue
and the internally used arrays for the column attributes are allocated dynamically,
which avoids any hard coded limit at all.
For the issue see
http://redmine.blackboxframework.org/issues/50.
For the changes see
http://redmine.blackboxframework.org/pr ... aa030749d1.
For the user there is no observable difference and no incompatibility.
- Josef
Re: issue-#50 unlimited number of columns in SqlControls.Con
Posted: Fri May 29, 2015 6:45 pm
by Zinn
Hello Josef,
you are doing a great job.
I add your improvements about the subsystem Sql to the CPC edition RC6 built 43 (not published yet).
During my comparison I find out that one topic is missing.
See Displaying SQLite table via "Sql Table Control" inside Form
at
http://community.blackboxframework.org/ ... ?f=19&t=81
The solution there there adds an if block into the procedure Restore.
Code: Select all
PROCEDURE (t: Table) Restore (f: Views.Frame; l, t1, r, b: INTEGER);
VAR row, col, x, y, w: INTEGER; data: SqlDB.Row; font: Fonts.Font;
width, mode: POINTER TO ARRAY OF INTEGER;
BEGIN
IF (t.table # NIL) & t.table.Available() & (t.table.columns > 0) THEN
IF t.table.columns > t.columns THEN (* resize dynamic arrays *)
width := t.width; NEW(t.width, t.table.columns);
mode := t.mode; NEW(t.mode, t.table.columns);
IF (width # NIL) & (mode # NIL) THEN
CopyArray(width, t.width);
CopyArray(mode, t.mode)
END;
FillArray(t.width, t.columns, t.table.columns - t.columns, defColW);
FillArray(t.mode, t.columns, t.table.columns - t.columns, center);
t.columns := t.table.columns
END;
DEC(t.rowH, t.rowH MOD f.unit);
Without this change the sample there produce a trap.
Sorry that I didn't write a note earlier.
Re: issue-#50 unlimited number of columns in SqlControls.Con
Posted: Mon Jun 01, 2015 10:36 am
by Josef Templ
Good point. The arrays may need to be resized in Restore because the table could have been changed
by executing a different SELECT statement.
However, resizing is the same as in FormatOps.Do. So I will refactor it a bit
instead of replicating the code.
When reading the mentioned forum discussion I found another hint to a potential problem.
Loading a table with zero columns leads to a TRAP because NEW cannot allocate an array with 0 elements.
I thought that this can never happen, but it can.
So I also have to add an "IF columns = 0 ..." in Internalize.
- Josef
Re: issue-#50 unlimited number of columns in SqlControls.Con
Posted: Mon Jun 01, 2015 11:25 am
by Josef Templ
topic branch issue-#50 contains the fixes.
Helmut, can you please review and test them?
For the diffs see:
http://redmine.blackboxframework.org/pr ... aa030749d1.
The test version can be found under
http://blackboxframework.org/unstable/issue-%2350/.
Build number 177.
- Josef
Re: issue-#50 unlimited number of columns in SqlControls.Con
Posted: Thu Nov 26, 2015 11:34 am
by Josef Templ
I have found and fixed 2 bugs in SqlControls.CheckPos.
- Josef