(this code is not working)
Code: Select all
function p_OwnLoop(key, value, local sublevel)
if sublevel < 5
sublevel=sublevel+1
foreach (table, p_OwnLoop(sublevel)
else
do something
endif
endfunction
What I am in pracitce trying to do, is to go through every shoe stored in table. However, Shoes are in way of "Gabor 51.320.27 Size 5", which makes this multidimensional table ([Brand][numbers1][numbers2][numbers3][size])
Since I can only do the thing i want when i reach the size point, I am trying to figure out a way to go through every item, and only do the thing after the size point is reached (which is reason for if sublevel < 5)
For this reason I would want to keep looping through same function using foreach command, but i somehow need to know in which sublevel (brand, numbers 1 - 3, size) I am going, so when i reach the Size point, Function knows to do something else.
My first idea was to use global variable sublevel, but then i realised it would keep increasing even beyond 5. So my current idea would be to use Local sublevel variable which I think would solve the problem, but question is, how can i (or can i) pass the variable sublevel to next foreach loop and have it as local variable.