handlers not firing

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

handlers not firing

Post by 2hup » Thu Nov 19, 2015 4:46 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: handlers not firing

Post by dunbarx » Thu Nov 19, 2015 9:10 pm

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

2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

Re: handlers not firing

Post by 2hup » Thu Nov 19, 2015 9:38 pm

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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: handlers not firing

Post by dunbarx » Thu Nov 19, 2015 10:46 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: handlers not firing

Post by Klaus » Thu Nov 19, 2015 11:32 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: handlers not firing

Post by FourthWorld » Thu Nov 19, 2015 11:37 pm

The useful thing about the startup message is that it's a very convenient way to do initialization unique to a standalone.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: handlers not firing

Post by jacque » Fri Nov 20, 2015 6:44 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

2hup
Posts: 24
Joined: Tue Nov 17, 2015 8:03 pm

Re: handlers not firing

Post by 2hup » Thu Dec 03, 2015 8:30 pm

Thank you Jacque - that looks like a good solution.

Brad

Post Reply