check table

is there a way to check if every entry in a table or a set of entries in a table is all a specific value??
example
 

 for i = 1, 10 do tableentry[i] = false; end

then later i change them 1 by 1 to be true, and i want at the very end, to check if they are all true and if yes run a function

local myTable = {} -- your table local counter = 0 -- your counter -- create 10 entries, set them all to false for i = 1, 10 do myTable[i] = false end -- checks table values, if they are false increase counter by 1 local function checkEntries() for i = 1, #myTable do if myTable[i] == false then counter = counter + 1 end end end -- run the function checkEntries() -- compare counter to total entries, if equal, it means they were all false, so change them to true if counter == #myTable then for i = 1, #myTable do myTable[i] == true end counter = 0 -- reset the counter to use again end

The same approach can be used to test if all table entries are true, then if they are, run your function.

that solves the problem with if they are all true,
but what if i want to know that 4, 8 , 14-20 are false?
is there a way to check that or do i have to do that manually?
without knowing that its actually 4,8 14-20
but could also possibly be 2–6, 20-26 and 28
as i might not know when i code it

random, 

what are you using the table for? is this a table of display objects, where you have some parameter of those objects which can be true or false? 

Jim

i rewrote some of the code so i could just use your example for all of it. thanks for the help

local myTable = {} -- your table local counter = 0 -- your counter -- create 10 entries, set them all to false for i = 1, 10 do myTable[i] = false end -- checks table values, if they are false increase counter by 1 local function checkEntries() for i = 1, #myTable do if myTable[i] == false then counter = counter + 1 end end end -- run the function checkEntries() -- compare counter to total entries, if equal, it means they were all false, so change them to true if counter == #myTable then for i = 1, #myTable do myTable[i] == true end counter = 0 -- reset the counter to use again end

The same approach can be used to test if all table entries are true, then if they are, run your function.

that solves the problem with if they are all true,
but what if i want to know that 4, 8 , 14-20 are false?
is there a way to check that or do i have to do that manually?
without knowing that its actually 4,8 14-20
but could also possibly be 2–6, 20-26 and 28
as i might not know when i code it

random, 

what are you using the table for? is this a table of display objects, where you have some parameter of those objects which can be true or false? 

Jim

i rewrote some of the code so i could just use your example for all of it. thanks for the help