Has the cancel message command changed?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

Has the cancel message command changed?

Post by Ron Zellner » Wed Nov 19, 2008 8:06 pm

I have a stack that I developed a couple of years ago that had a cancel message command in it, I believe it worked then:

else cancel Next checkMouseWithin

The intent is to cancel the "checkMouseWithin" command if a box is checked (the "checkMouseWithin" is in a loop that calls itself and continues otherwise)

I get a "cancel: message id is not an integer" error message.

Is there a better way to do this?

Here is the original script as it appears in the current editor:

Code: Select all

on mouseUp
  if the hilite of me is true
  then send "checkMouseWithin" to group 1
    else cancelNextCheckMouseWithin
end mouseUp


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

Post by Klaus » Wed Nov 19, 2008 9:36 pm

Hi Ron,

nope, the way "cancel" works has not been changed, you said "I believe it worked then..." but I bet it didn't :-D

Please check the docs for "send ... in..."!

After you fired a "send in" you will have to check "the result" immediately and store it in a variable or custom prop for later use, since "the result" will contain the "message id" that you can cancel later. And that explains your error message.

...
global message_id_2_cancel
send "do_this_or_that" to me in 2 secs
put the result into message_id_2_cancel
...

And later, maybe in another handler:
...
global message_id_2_cancel
cancel message_id_2_cancel
...


Best from germany

Klaus

Post Reply