working method?

Dick Kriesel dick.kriesel at mail.com
Thu Oct 27 02:57:39 EDT 2005


On 10/26/05 10:09 PM, "Jim Ault" <JimAultWins at yahoo.com> wrote:

<snip>
> --All simple button mouseup scripts are identical
> on mouseUp
>   do (the short name of me)
> end mouseUp
> --set the LABEL of the btn for the user, the NAME for the program
> 
> on mouseDoubleDown
>   do (the short name of me &"down")
> end mouseDoubleDown
> 
> on mouseStillDown
>    do (the short name of me &"stilldown")
> end mouseStillDown
<snip>

You could avoid having separate scripts in all those simple buttons by
applying the library idea.  A library stack that you might call "simple
buttons.rev" could have handlers like the following that serve all those
buttons on all those cards in all those stacks:

on mouseUp
  if the script of the target is empty then -- simple buttons only
    do short name of the target
  end if
  pass mouseUp -- authors agree to pass system messages in libraries
end mouseUp

on mouseDoubleDown
  if the script of the target is empty then
    do short name of the target & "_" & param(0)
  end if
  pass mouseDoubleDown
end mouseDoubleDown

on mouseStillDown
  if the script of the target is empty then
    do the short name of the target & "_" & param(0)
  end if
  pass mouseStillDown
end mouseStillDown

The "library" working method can help reduce code redundancy and increase
code reuse.  And it packages related behavior to simplify not just finding
scripts but also upgrading them.

The library method works for application domain objects' behavior as well,
like for contacts, customers, and orders.

-- Dick





More information about the use-livecode mailing list