passing quotes parameters to a 'send' message...

Dar Scott dsc at swcp.com
Wed Jul 13 15:40:06 EDT 2005


On Jul 13, 2005, at 1:03 AM, Chipp Walters wrote:

> Thanks, that is just too weird. Doesn't seem like it *should* work, 
> but it does.

If you like weird, try this:

on mouseUp
   send "beep -- herald something" to me
   send "set the backcolor of me to red" to button "B"
end mouseUp

This works.  Even if you add 'in <fakeDelay>', you can see the 
"handler" is named "set" in the pendingMessages().

Now just when that and invoking a custom command with variable 
parameters in a send start to make sense, try this:

on mouseUp
   put blue into newColor
   send "beep -- anounce something" to me
   send "set the backcolor of me to newColor" to button "B"
end mouseUp

That fails with "can't find hander ... set".

Now if you try 'in <fakeDelay>', you can still see the message in 
pendingMessages(), but because it is 'in <fakeDelay>', then there is no 
error message if the handler is not found (the color is not changed).

However, this works just fine:

on mouseUp
   put blue into newColor
   do "set the backcolor of me to newColor"
end mouseUp

Except it is now the button you clicked not "B" that is changed.  And 
'do' will work just fine with a custom command with variable 
parameters.

Try this:

on mouseUp
   put blue into newColor
   send "put newColor after message" to button "B"
end mouseUp

Y' get "newColor" added to the message box.

So what is the one case that is different?  It is the lack of the 
ability to use variable parameters in non-custom commands.  IMHO, that 
is the weird part.  But maybe that is a good thing.

Try this:

on mouseUp
   send "dosomething v()" to me in 2 seconds
end mouseUp

function v
   beep
   return 5
end v

on doSomething x
   put x after message
end doSomething

I hear the beep and then two seconds later the 5 is added to the 
message box.

on mouseUp
   send "put the backcolor of me after message" to button "B"
end mouseUp

That displays the color of button "B".  If that weird part I mentioned 
above is "fixed", then that would probably change.  Maybe we don't want 
it to.  I'm OK with the change.

Dar

-- 
**********************************************
     DSC (Dar Scott Consulting & Dar's Lab)
     http://www.swcp.com/dsc/
     Programming and software
**********************************************




More information about the use-livecode mailing list