Repeat loops in closeStack?
Posted: Thu Feb 28, 2019 3:53 pm
I was spending some time on the text editor today, and decided that I would create a loop that would be fired in the 'closeStack' handler that would close all the cards in the stack after finding out if the user wanted to save any of their contents.
I think my mind is not right again, because when it gets to the line "close card tmpNum", it jumps out of the repeat loop (there is 2 cards in the stack while running) and goes back to beginning of the closeStack handler.
I thought unless you coded an exit to a repeat, that wouldn't/couldn't happen?
At first, i thought it was because of a 'preOpenCard' handler I was testing, but I commented that out and it still happens. Any thoughts?
Code: Select all
on closeStack
if field "textEditor" is not "" or the number of cards of this stack > 1 then
answer "Would you like to save your work?" with "No" or "Yes"
if it is "Yes" then
saveDocs
else
put the number of cards of this stack into tmpNum
repeat with x=tmpNum down to 0
close card tmpNum
if the number of this card is "1" then put "" into field "textEditor"; put "" into field "saved"; put "" into field "filePath"
end repeat
end if
end if
pass closeStack
end closeStack
I thought unless you coded an exit to a repeat, that wouldn't/couldn't happen?
At first, i thought it was because of a 'preOpenCard' handler I was testing, but I commented that out and it still happens. Any thoughts?