Have a nice and restful day Yafuhenk!
I have worked out a solution as I outlined in this post
here
I have attached Klaus’s zip file with the modifications.
I have tried to minimize the impact to LoadSQLiteDB, i.e. it’ll behave normally and is backwardly compatible with V1.42 and your old code will work without changes. No new Type has been introduced and very few Global variables.
If you want to take advantage of the formatting features, you only need to call a new class method: SetSQLColumnFormat before calling LoadSQLiteDB.
LoadSQLiteDB will detect whether there are columns (0, 1 or more) that require formatting and will apply it. The formatting is simply of these types:
TypeInt
TypeText
TypeReal
TypeImage
TypeImage is not implemented, but could be in the future?
The formatting is forgiving, i.e. if you type a column as Real and the real value is text, you’ll end up with “0.0” but no exception will be raised. And if use TypeText for a Real column, the result will be as erroneous as before
Initiating the formatting is done this way:
Table1.SetSQLColumnFormat(Array As Object ( Array As Int(0, Table1.TypeInt) _
,Array As Int(2, Table1.TypeReal)))
Each entry is column number (as per the query order) and its data type. The entries in the array need not be in order.
In the demo, 4 columns are displayed from the test table, but only two are formatted. I have introduced some null in the data for testing purpose.
To disable Column Formatting, if you had enabled it, call the method with null:
Table1.SetSQLColumnFormat(Null)
I have done quite a bit of testing, but it would be nice to get more, so guys if you are interested
Now, you may prefer to keep the original LoadSQLiteDB as is and call this one LoadSQLiteDBxxxx.
BTW, I have set Table1.SetAutomaticWidths in the demo, so if you want to use a large sample data, be aware of this.
Claudio