127 posts
Posted 03 January 2013 - 05:43 AM
for i,v in ipairs(filelist) do
if string.lower(string.sub(v,#v-3,#v)) == ".ico" then
table.remove(filelist,i)
end
end
so got this code, and well it seems that because of the fact i remove the input(i) from the table if it ends in ".ico" i think it messes up the order that it goes in, for example say i=5 and v does end in “.ico” it deletes it, but now 6 has become 5, meaning that it actually skips that particular number, any solutions to this?
Much Appreciated
871 posts
Posted 03 January 2013 - 06:11 AM
this was covered pretty extensively a few days back in
this thread, there are multiple possible solutions listed there.
1054 posts
Posted 03 January 2013 - 06:13 AM
Quick and dirty solution is to use 'pairs' because it uses a different way of indexing that can handle this. :)/> (each key has a pointer to the next key)
Edit: GopherAtl's answer is more thorough. :)/>
2005 posts
Posted 04 January 2013 - 08:14 AM
For removing entries from an iterative table, I prefer to decrement a numeric for loop. But using pairs would be safer.