Array of structure; OK in IDE, not in compiled

mjcoon

Well-Known Member
Licensed User
I have been happily running under the desktop IDE using the following code:

B4X:
      TabFullList.LoadXML(readFile)
      For counter = 0 To ArrayLen(TabFullWidths()) -1
         TabFullList.ColWidth(TabFullWidths(counter).Name) = TabFullWidths(counter).Width
      Next

I found I needed this because though when I do TabFullList.LoadCSV the column widths are retained, when I do TabFullList.LoadXML they are all reset (including columns meant to be invisible). So the array is declared as:
B4X:
   Dim Type ( Name, Width ) TabFullWidths(0)

and initialised with the column widths I want.

This works running under the desktop IDE but not when compiled for desktop or device. So am I getting away with some wrong syntax?

Mike.
 

mjcoon

Well-Known Member
Licensed User
Where do you redeclare the array with the actual size?

Thanks Erel, I do that with the Array keyword, since the values are chosen by me and compiled-in:

B4X:
   TabFullWidths() = Array(("colRowNumber", 0), ("colLegNumber", 20), _
                     ("colPointNumber", 33), ("colDateTime", 125), _
                     ("colTimeTicks", 0), ("colStart", 10), ("colLat", 50), _
                     ("colLong", 50), ("colDistance", 50), ("colSpeed", 50))

I also have alternative column widths arrays (just one so far) so the user can switch between views of the data. The arrays will always have the same length to cover all the columns. Admittedly it gets inefficient to store the column names each time.

Mike.
 

agraham

Expert
Licensed User
Longtime User
I'm afraid that I can't see anything wrong with this. :confused:
The following compiles and works for me under 6.80 and 6.87.
B4X:
Sub Globals
  'Declare the global variables here.
  Dim Type ( Name, Width ) TabFullWidths(0)
End Sub

Sub App_Start
  TabFullWidths() = Array(("colRowNumber", 0), ("colLegNumber", 20), _
    ("colPointNumber", 33), ("colDateTime", 125), _
    ("colTimeTicks", 0), ("colStart", 10), ("colLat", 50), _
    ("colLong", 50), ("colDistance", 50), ("colSpeed", 50))         
  counter = 0
  TabFullWidths(counter).Name = "test"
  Msgbox( TabFullWidths(counter).Name)            
End Sub
 

mjcoon

Well-Known Member
Licensed User
I'm afraid that I can't see anything wrong with this. :confused:
The following compiles and works for me under 6.80 and 6.87....

Thanks for looking at that Andrew. I must verify that the test for the array length works too, since if that delivers zero it would give the same effect.

Cheers, Mike.
 

mjcoon

Well-Known Member
Licensed User
I must verify that the test for the array length works too, since if that delivers zero it would give the same effect.

Yes, well, I did that, and there was no problem.

The problem is really to do with the LoadXML. So I shall start a new thread (not under bugs, yet) with a sample program source, derived from my real program, that shows the problem.

Mike.
 
Top