PDA

View Full Version : Can i use Table.Concat like this ?


qwerty
02-17-2009, 02:46 PM
i find myself in the situation where i want to loop through a table reading the data from every other line in the table into a list box, so i was thinking to try using Table.Concat with no separator declared, and a matching index for the start and stop points.... would this effectively allow me to read just that one line ?


here is what i have so far


-- Transfer from chunkTable to List Box --
item_count = Table.Count(chunkTable);
ind = 1;
ListBox.DeleteItem("FileSizeList", LB_ALLITEMS);
for x = 1, (item_count/2) do
ListBox.InsertItem("FileSizeList", x, "Piece ".. x, Table.Concat(chunkTable, "", ind, ind));
ind = ind+2;
ListBox.SetUpdate("FileSizeList", true);
end



i'm not entirely sure if i need to use the SetUpdate thing or not, i only really need it to update at the end of the loop, but if it takes a while to populate then updating on each step could be handy

i also have the same data in a text file, but thought it might be easier to do it this way from the table

yosik
02-17-2009, 03:40 PM
FYI, in the for statement, you can use step. Wouldn't that be easier?
Yossi

qwerty
02-17-2009, 04:33 PM
sorry, you lost me i'm afraid .... but i did find an alternitive way of doing it...

in the original table, when it was created, there was a number of aditional characters and things in each index which i did not need, or wanted to change, so when i was creating the original table in the function i use for that, i make it create a second table with only the data i needed in each element plus the aditional text i wanted, so now i can use this

-- Transfer Data from chunkSizeTable to List Box --
item_count = Table.Count(chunkSizeTable);
ListBox.DeleteItem("FileSizeList", LB_ALLITEMS);
for j,k in chunkSizeTable do
ListBox.InsertItem("FileSizeList", j, "Piece ".. j, k);
ListBox.SetUpdate("FileSizeList", true);
end

Desrat
02-17-2009, 07:20 PM
Use a loop with a step is what yosik was suggesting

-- A for loop that counts from 1 to 10 in 2's
min = 0; -- The number to start at
max = 10; -- The number to stop at
step = 2; -- The number to count by (in this case 0, 2, 4, ...)
for count = min, max, step do
-- Do something here
end

qwerty
02-17-2009, 07:52 PM
http://i139.photobucket.com/albums/q301/ghost_industries/80cee2951b4c1cf96e17ff727c492f25.gif ok now i'm with you :p

and yes, that would have worked better than what i had, but writing a second table on the fly with the first one has actually allowed me to alter the way i display the data which is better for me :) live and learn as they say


ok, so thats this one solved ... appreciate the help guys, and i will certainly remember this for next time :)


now to find out why my File.GetSize action is returning a value lower than 250mb when applied to a 4.09gb img file :(... back to the search engine i go !