Send command only works in Message Box

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Send command only works in Message Box

Post by townsend » Mon Jul 02, 2012 3:54 pm

I've got a Label Field where I put little status messages.
But I only want them to stay there for 10 seconds.
So I wrote a little function to clear the status field in 10 seconds.

Code: Select all

     put "File Saved..." into fld "status" of this stack
     send "call clear.status()" to this stack in 10 seconds

    function clear.status
         beep
         put empty into fld "status" of this stack
    end clear.status
But the clear.status() function gets executed immediately,
instead of 10 seconds later. The strange thing here is,
if I put that same exact, Send line of code, in the Message Box, the
clear.status() function gets executed 10 seconds later, the way it should.
Any idea what I'm doing wrong?

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

Re: Send command only works in Message Box

Post by Klaus » Mon Jul 02, 2012 3:59 pm

A function should return something, so maybe you better create a handler here?
At least that's what I would do 8)

Code: Select all

...
  put "File Saved..." into fld "status" of this stack
  send "clear.status" to this stack in 10 seconds
...

command clear.status
   beep
   put empty into fld "status" of this stack
end clear.status
Then you do not need to mess around with "call", which is not necessary here.

But the message box has some known flaws, do not rely on it!


Best

Klaus

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Send command only works in Message Box

Post by townsend » Mon Jul 02, 2012 4:16 pm

Thanks again Klaus!

That worked. Interesting note though. Usually when I call a handler or function,
I like to put the "Call" in there just to make my code more readable.
But in this case, with the added, Call, the beep sounded,
but the put empty command does not work. That's odd.

So-- from now on, I'm going to stop using the unnecessary Call prefix,
and make my handler names distinctive some other way.

Post Reply