I tried writing a floodFill program ( shown in another post ) using a recursive call, but I got a “stack overflow” error message and had to use a table instead. I was just wondering what the “stack overflow” limit was on other iPads. Run this code. The first time it will look like it’s not doing anything while doing the recursive calls. When you get the stack overflow message, exit back to the editor and run the program again. The first time the program is run, “recursive” in global data will be nil and it will do the recursive calls and save the count in global data. The second time, “recursive” will have a value that will print. On my 16gb iPad 1, it takes about 14 seconds before I get the “stack overflow” message. My recursive count is 16381. If you want to run this multiple times, uncomment the “saveGlobalData” line to set recursive to nil. Re-comment the line and run again.
function setup()
--saveGlobalData("recursive",nil) -- set recursive to nil
a=readGlobalData("recursive") -- read recurvive value
print(a) -- print nil or recursive value
if a==nil then
count=0 -- set count to 0
recursive() -- call recursive
end
end
function recursive()
count = count + 1 -- add 1 to count
saveGlobalData("recursive",count) -- save count in recursive key
recursive() -- call function recursive
end