Page 1 of 1

closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:02 pm
by tetsuo29
Any ideas why this:

Code: Select all

on closeStack
   -- stop the timer
   if sTimerState is "running" then
      put "stopping" into sTimerState
   end if
   wait 1 seconds
  pass closeStack
end closestack
Is now producing this error in LC 9.6 (on Linux and Windows haven't test on Mac yet):
stack "Count It Down": execution error at line 277 (wait: aborted), char 1
Line 277 is:

Code: Select all

wait 1 seconds
I originally made this app in 2018, I forget which version of LC I was using but, it wasn't causing this error.

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:12 pm
by Klaus
Just made a fresh new stack with no controls, added your script and closed it without any error.
macOS 10.14.6, LC 9.6

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:17 pm
by tetsuo29
I should clarify, this error is happening when closing the IDE with the stack open.

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:30 pm
by Klaus
Aha, OK, just tested and still no error!?

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:44 pm
by dunbarx
Hi.

I will test also, but how are you closing the IDE? The handler you posted will not do so.

Craig

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:45 pm
by Klaus
Maybe just QUIT? 8)

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:56 pm
by tetsuo29
dunbarx wrote:
Thu Jul 09, 2020 4:44 pm
Hi.

I will test also, but how are you closing the IDE? The handler you posted will not do so.

Craig
Just by choosing "Quit" from the File menu.

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:56 pm
by dunbarx
Not sure what is pertinent here, but in a new stack with this in the card script:

Code: Select all

on closeStack
   -- stop the timer
  -- if sTimerState is "running" then
      --put "stopping" into sTimerState
 --  end if
  --- wait 1 seconds
   pass closeStack
end closestack
The stack window stays visible, even though the handler (visible because I was working from there) in the SE is deleted. Sending "closeStack" to the card by msg does the same thing. Of course, sending "close this stack" actually closes the stack.

The closeStack message is sent when the stack closes, and is not the trigger for that action just because it passes through that stack. But then why does the SE close the card script tab?

Craig

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 4:58 pm
by dunbarx
Just by choosing "Quit" from the File menu.
But that has nothing to do with your original issue, no?

Klaus, how did you do it? Same way?

Craig

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 5:01 pm
by Klaus
Sure, since QUIT will close all stacks and they receive a "closestack" message.

BUT I raised the WAIT to 4 seconds and now I also see this error! :shock:

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 5:15 pm
by Klaus
After reading up the dictionary, I am not sure if this is not desired behavior!?
Could you do this on closestackrequest?
That seems to be the right message for this.

Re: closestack handler wait 1 second error

Posted: Thu Jul 09, 2020 6:49 pm
by tetsuo29
Klaus wrote:
Thu Jul 09, 2020 5:15 pm
After reading up the dictionary, I am not sure if this is not desired behavior!?
Could you do this on closestackrequest?
That seems to be the right message for this.
That did the trick! Thank you!

Of course, this is making me think that any things you might want to do before allowing a stack to close are safer in a closeStackRequest handler than they are in a closeStack handler because it now seems apparent that if something in your closeStack handler takes too long, it can generate an error.

Re: closestack handler wait 1 second error

Posted: Fri Jul 10, 2020 5:30 pm
by jacque
Note that closeStackRequest only fires if the user clicks the close box in the window title bar, it won't fire when quitting or closing the stack from a script.

Since you're quitting anyway, it doesn't seem necessary to reset the timer.