Messages

Jim Ault JimAultWins at yahoo.com
Sun Sep 4 20:12:13 EDT 2005


Well, Mark, a bit more socially acceptable would be to use the form

send "me" to "washroom" in 30 minutes to pSomething

rather than every time a drink is offered.
Reading your code aloud did make me laugh.

>   if pSomething is "Guinness" then
we would know the button did it.

Jim Ault


On 9/4/05 11:13 AM, "Mark Wieder" <mwieder at ahsoftware.net> wrote:

> Tom-
> 
> And just to make things a bit clearer:
> 
> There are three objects drinking at a bar:
> A button, a card, and a stack.
> The button only drinks Guinness
> The card only drinks Bud Light
> The stack will drink anything with alcohol
> 
> They each have a Drink handler:
> 
> in the button handler:
> on Drink pSomething
>   if pSomething is "Guinness" then
>     answer "the button drank it"
>   else
>     pass Drink pSomething
>   end if
> end Drink
> 
> in the card handler:
> on Drink pSomething
>   if pSomething is "Bud Light" then
>     answer "the card drank it"
>   else
>     pass Drink pSomething
>   end if
> end Drink
> 
> in the stack handler:
> on Drink pSomething
>   if HasAlcohol(pSomething) then
>     answer "the stack drank it"
>   else
>     pass Drink pSomething
>   end if
> end Drink
> 
> The button also has a mouseUp handler:
> on mouseUp
>   Drink field "fromBartender"
> end mouseUp
> 
> (and there's also obviously a field called "fromBartender")
> 
> Now put something into the "fromBartender" field and click the button.
> The button's mouseUp handler sends the "Drink" message out to see who
> catches it. And do check out Richard's writeup on this. Here's a
> bonus: once you get the concept of messages, everything else falls
> into place pretty easily.
> 
> Saturday, September 3, 2005, 12:19:32 PM, Dan wrote:
> 
>> Great analogy.
> 
> Indeed.





More information about the use-livecode mailing list