Page 1 of 1

handlers not firing

Posted: Thu Nov 19, 2015 4:46 pm
by 2hup
Hello LiveCoders!

In my application I have some of handlers that were to be working until yesterday, but now the code never gets executed. I have gone through every part of LiveCode I can find, but I cannot figure out how to fix this. In particular, I have a startup handler in the script for my main stack that opens and creates the database. Without that code executing, everything else fails.

btw - I noticed my version was 7.06, so I upgraded to the latest stable version - 7.1.0 Build 10043.

EDIT...

ok, so not sure how I ever got that to work in the first place. I created new stack, added the handler, it seems there isn't a startup message (when I watch the messages.) So which message should I be using? There is a resumeStack message. I guess I will try that.

EDIT...
I am going to try the openStack message. If anyone has any feedback, great, otherwise I will consider this closed.

Re: handlers not firing

Posted: Thu Nov 19, 2015 9:10 pm
by dunbarx
Hi.

Code: Select all

I am going to try the openStack message.
If you think about it, giving the handler name is critical to helping you. What had you used before?

Think also about using an "openCard" handler in the stack script. This fires a bit after the stack has loaded, since the first card has to load as well, and catches things that "openStack" (and certainly "preOpenStack") will not. It is good practice, unless you explicitly need to do work early in the stack loading process.

Craig

Re: handlers not firing

Posted: Thu Nov 19, 2015 9:38 pm
by 2hup
Thanks Craig!
I was using startup, which shows up in the dictionary - maybe it is deprecated? I never could see the message in the message watcher.
so far openStack is working fine. Thanks!

Re: handlers not firing

Posted: Thu Nov 19, 2015 10:46 pm
by dunbarx
Hi.

Startup is not deprecated, but depending on what you are up to, it may fire too early in the, er, startup process, and miss stuff. You cannot appreciate this until it bites you. That is why, unless, as I said, there is a reason to trap a very early message, trap a late message instead. Usually, the intent is to do something when the stack "opens". But this invariably can wait until all the objects are loaded, and, you might say, the stack has indeed "opened".

Craig

Re: handlers not firing

Posted: Thu Nov 19, 2015 11:32 pm
by Klaus
Hi 2hup,

1. welcome to the forum! :D
2. The "startup" message is caught by the LC IDE, this will only work in your standalone(s)!


Best

Klaus

Re: handlers not firing

Posted: Thu Nov 19, 2015 11:37 pm
by FourthWorld
The useful thing about the startup message is that it's a very convenient way to do initialization unique to a standalone.

Re: handlers not firing

Posted: Fri Nov 20, 2015 6:44 pm
by jacque
I usually use preOpenStack or openstack to get around the IDE trap. Using opencard can cause interference if the stack has more than one card.

Or you can have the best of both worlds:

Code: Select all

on preOpenStack
  if the environment is "development" then startup
end preOpenStack

Re: handlers not firing

Posted: Thu Dec 03, 2015 8:30 pm
by 2hup
Thank you Jacque - that looks like a good solution.

Brad