B4J Question B4XTable Crashes with 8 Columns But Not With 7

cklester

Well-Known Member
Licensed User
If you run the attached B4XPages project, the app will crash when you attempt to search the B4XTable.

If you comment out line 30, reducing the table column count from 8 to 7, you can search just fine. No problem.

I also tried with 9 and 999 rows. The number of rows does not seem to matter.
 

Attachments

  • b4xtable_column_count_bug.zip
    9 KB · Views: 244

emexes

Expert
Licensed User
You've probably already tried this but, in the programming fog-of-war, sometimes things slip by ? :

is it possible, when you set the table to 8 columns, that B4XTable1.SetData is expecting newrow()s of 8 strings, not 7 ?

B4X:
Private newrow(7) As String
...
B4XTable1.SetData(randList)
 
Upvote 0

cklester

Well-Known Member
Licensed User

It's seemingly irrelevant, as both are receiving only newrows() of 4 strings.

In both cases, I am passing fewer-than-expected columns of data. Only the table with 8 columns crashes.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Only the table with 8 columns crashes.
It is not so. The size of the array must match the number of columns.

Try so, commenting/uncommenting some AddColumn lines.
B4X:
    Private randList As List
    randList.Initialize
    Private i As Int
    For i = 0 To 99
        Private newrow(B4XTable1.Columns.Size) As String
        Private x As Int
        For x = 0 To B4XTable1.Columns.Size - 1
            newrow(x) = RandomString(3)
        Next
        randList.Add(newrow)
    Next

    B4XTable1.SetData(randList)
 
Upvote 0

cklester

Well-Known Member
Licensed User
I wonder, then, if an error message should be produced when trying to use SetData() with a list of arrays that aren't enough.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…