Having data save problems with a List

fdx12345

Active Member
Licensed User
Longtime User
I am using a List to store data. I manually enter the first row of data and the rest I fill via a loop.

B4X:
   Dim headerS(NumberOfColumns) As String
   Dim allListData As List
              Dim config(NumberOfColumns) As String

   allListData.Initialize
   allListData.Clear

   config(0) = "x"
   config(1) = "x"
   config(2) = "x"
   config(3) = "x"
   config(4) = "x"
   config(5) = "x"
   config(6) = "x"
   
   allListData.Add(config)
"line A" ---->   config = allListData.Get(0) 'verify data was saved correctly


   For i = 1 To 12
      tableHeader.Initialize("")
      tableHeader = BudgetTable(i).RetrieveHeader
      headerSize = headerS.Length
      For j = 0 To headerS.Length - 1
         L = tableHeader.GetView(j)
         headerS(j) = L.Text
      Next
      allListData.Add(headerS)
"Line B" -------->      config = allListData.Get(0)  'verify the first row is still there
Line C ----->      config = allListData.Get(1) 'verify second row is fine
   Next

What is happening is the "x" on the first row is stored correctly via the readback on line A but it is erased when I check it on line B

Also the second line of data (first loop through the For loop) is initially stored correctly but when I check it after the second pass, the data seems to have been over-written by the 3 line of data. The check is done on line C. All of these checks is for debugging only and the Line A, B, C is just to point out the area I am using to you guys.

I do not know why the intial line of data (row 0) is being erased (x replaced with "") or why the 1st rowof data in the for loop is being over-written with the 2nd row of data from the loop
 

mangojack

Expert
Licensed User
Longtime User
I might be off the mark here but try ..

replace
B4X:
allListData.Add(config)

with
B4X:
allListData.AddAll(config)

also make the change when adding the headerS array

Cheers mj
 
Upvote 0

fdx12345

Active Member
Licensed User
Longtime User
Never thought about that

I will give it a try. I am about ready to try a different route if this does not work.
 
Upvote 0

fdx12345

Active Member
Licensed User
Longtime User
did not quite work

I have several Tables (Table class) set up as an array ie Tables(1-13) and I need to save the header to each table as they can differ from one table to the next. I am using saveCSV to handle all of the work (which it does fine with the data and one row of headers if I use saveCSV2, but it does not handle an array of headers from an array of tables.

The ADDAll went well for addition, but bombed in the saveCSV.

It was a challange to figure out how to push 13 tables of data into one file via one SaveCSV command but I did it. However, trying to do the same for the Headers, has turned out to be a worse headache. I hate to create another file just for headers but may go that direction and maybe just use TextWriter. Of course, I have to read that file back and put everything back into its respective place in its respective table.
 
Upvote 0

fdx12345

Active Member
Licensed User
Longtime User
Thank you

OK, now I see the problem though I don't agree with the way Java handles such things. Seems like Java is pretty primitive compared to "C" or even Visual Basic.
 
Upvote 0
Top