Page 1 of 1

on suspendStack trapped

Posted: Thu Apr 02, 2015 7:26 pm
by MrAlobar
I'm in a trap...

Trying to debug my app which uses the suspendStack message (to carry out some tasks when the app loses focus).

I trod the well worn path of inserting 'answer...' in the handler, but now I am trapped in a loop between the IDE and the stack...

Using the IDE suspends the stack, which pops up the answer box, which locks everything until the 'ok' is clicked, which of course resumes the stack, ready to repeat again..

Anyone know the solution - ctrl '.' doesn't work.
Couldn't find anything from a google search, nor search of this forum.
I can't be the first to fall down this hole, surely !

Cheers,
Jay

Re: on suspendStack trapped

Posted: Thu Apr 02, 2015 7:50 pm
by MrAlobar
...to answer my own question.. found after much experimenting...

send the answer box away (click ok)
click the code editor
send the answer box away again
ctrl tab hides the palettes
ctrl tab reveals the palettes
then click the code editor and editing is allowed

Variations on this worked too, the common thing being the two lots of ctrl tab.

Not sure why it works or what it is doing (locking messages maybe ?), not experimented any more than that and not seen it documented anywhere.

Can anyone enlighten me ?

Back to debugging again...

Re: on suspendStack trapped

Posted: Thu Apr 02, 2015 9:03 pm
by FourthWorld
Using "put" instead of "answer" will provide feedback in a way that doesn't keep sending suspendStack events.

There may be even better ways to debug such things, depending on what your suspendStack handler is doing. Can you share that handler so we can see what it needs to do?

Re: on suspendStack trapped

Posted: Fri Apr 03, 2015 11:03 am
by MrAlobar
Hi Richard,
Thanks for the suggestion of 'put', I'll try it.

My suspend handler is very simple and not the cause of the problem I was trying to track down...

on suspendStack
if gShrink is "true" then shrinkStack
pass suspendStack
end suspendStack

I inserted the answer message as the first line to report the state of certain aspects of the code.

On reflection, I think I need to learn to use the debug mode better, with step through and breakpoints - I'm missing a trick I think.

Re: on suspendStack trapped

Posted: Fri Apr 03, 2015 4:01 pm
by FourthWorld
Is gShrink declared in that script?

Re: on suspendStack trapped

Posted: Fri Apr 03, 2015 4:23 pm
by jacque
Whenever you find yourself in a situation where your script takes over like that, click on the Messages icon in the toolbar. That turns off all engine messages and the offending handler will no longer trigger. Then you can revise the script.

Remember to turn it back on again later or you'll wonder why nothing works.

Re: on suspendStack trapped

Posted: Fri Apr 03, 2015 7:15 pm
by MrAlobar
Hi FourthWorld,
Yes gShrink is declared - handler works fine.

Hi Jacque,
I tried that but no interaction with the IDE is possible.

Try creating a stack with nothing in it but an answer command in an on suspendStack.

Re: on suspendStack trapped

Posted: Fri Apr 03, 2015 10:26 pm
by SparkOut
This might be the opposite of what you need, but under tools, development menu, you could disable the development environment to see how your stacks behave without interference from the ide

Re: on suspendStack trapped

Posted: Sat Apr 04, 2015 10:29 am
by MrAlobar
Hi SparkOut,
Yep that is useful, I've used it a few times. But in this instance that trap still springs. The IDE cannot be disabled when the stack is running as clicking any button outside the stack send the suspend message, the dialogue needs acknowledging before anything else can be done, this is the loop trap.

Ctrl tab, ctrl tab is the way out, I'm just not sure why it works.

Re: on suspendStack trapped

Posted: Sat Apr 04, 2015 8:07 pm
by jacque
Try creating a stack with nothing in it but an answer command in an on suspendStack.
I tried it, but I'm not getting the same results. I do get the answer dialog when I click into the IDE but after dismissing it, I am able to work with the IDE stacks and objects, toggle toolbar icons, select from the tool palette, type into the message box, etc. I'm on a Mac if that makes a difference, and I tested in LC 6.7.3.

Re: on suspendStack trapped

Posted: Mon Apr 06, 2015 4:25 pm
by MrAlobar
That's interesting, thanks Jacque.
I'm on Windows 8.
I'll set up Mac OSX in a VM and try it.
It'll be next week as I'm away from my computer this week. I'll report back what I find.