Whither empty handlers?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Whither empty handlers?

Post by dunbarx » Fri Jan 08, 2016 11:28 pm

I did not know this. Not a big deal...

If you make a new button, and put this into its script

Code: Select all

on mouseUp
   testNothing
end mouseUp

on testNothing

end testNothing
and set a breakpoint at the "on testEmpty" line, that breakpoint is not caught. Same with a function call. It does not matter if you have spaces in the, er, empty space. The handler does not really exist until at least one character is between the keywords?

Craig Newman

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

Re: Whither empty handlers?

Post by jacque » Sat Jan 09, 2016 6:34 pm

You can usually put a breakpoint at the "end" line though. Or you can type the word "breakpoint" in the empty line.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Whither empty handlers?

Post by Klaus » Sat Jan 09, 2016 6:55 pm

I ususally refuse to ask this, but why would one do that? :D

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

Re: Whither empty handlers?

Post by jacque » Sat Jan 09, 2016 8:43 pm

Sometimes it lets you see the value of local variables without actually running any handlers, but that doesn't seem to work reliably. The only other case I can think of is if you have commented out the guts of a script and you want to see what hander called it. But there are other ways to do that too.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Whither empty handlers?

Post by dunbarx » Sat Jan 09, 2016 11:54 pm

Klaus.

What Jacque said. A variation:

Code: Select all

on mouseUp
   put random(999) into xx
   findVarVal xx
end mouseUp

on findVarVal xx
   -- what is xx?
end findVarVal
Commented lines are invisible as well, and that is actually how I discovered this silly thing. I just couldn't make a soft breakpoint fire.

Jacque. Insert a line that reads "breakpoint"? Why not just put in anything at all? :D Also, why "end" works, but not the "on"? (but who cares?)

Klaus. Do you think I just make this stuff up? :wink: As the three oldest LC'ers on the planet, we have to stick together

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

Re: Whither empty handlers?

Post by jacque » Sun Jan 10, 2016 4:11 am

Also, why "end" works, but not the "on"? (but who cares?)
I'm guessing the debugger can't work without knowing which handler it's in, and it can't know that until the declaration line executes.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Whither empty handlers?

Post by dunbarx » Sun Jan 10, 2016 6:18 am

Jacque.

Hmmm.

But then how does it know which handler it is in anyway? In other words, what does following content have to do with it?

I don't think this warrants much anguish. It just was interesting for a second.

Craig

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

Re: Whither empty handlers?

Post by Klaus » Sun Jan 10, 2016 12:23 pm

Hi Craig,
Klaus. Do you think I just make this stuff up? :wink:
YES! :D

No, of course not, I never had the need for this kind of trick, so I couldn't imagine its meaning :)
As the three oldest LC'ers on the planet, we have to stick together
Ah, the old "solidarnosc" thingie, OK 8)


Best

Klaus

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

Re: Whither empty handlers?

Post by jacque » Sun Jan 10, 2016 6:43 pm

dunbarx wrote:Jacque.

Hmmm.

But then how does it know which handler it is in anyway? In other words, what does following content have to do with it?

I don't think this warrants much anguish. It just was interesting for a second.

Craig
But I can't leave unresolved conversations alone. It's a compiler, it doesn't know anything until it's seen it. Same reason you have to declare script variables above any handler that uses them.

If we judge age by the number of posts then I think Klaus is the oldest. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply