Script Improvement Advice

Chipp Walters chipp at chipp.com
Thu Jun 5 00:19:00 EDT 2003


Hi Paul,

I'd probably use custom properties. I'd set the "myPeriodicProps" of button
"my_Hydrogen" to:

Hydrogen
1
1.008
37
N/A
etc..

and do the same with all the other buttons.

Then I'd make sure the button names all begin with "my_" and none of them
have a 'on mouseup' handler.

I'd put the following into the card script

on mouseUp
   if the short name of the target contains "my_" then
      put the myPeriodicProps of the target into tVar
      put line 1 of tVar into field "ElementNameField"
      put line 2 of tVar into field "AtomicNumberField"
      put line 3 of tVar into field "AtomicMassField"
      (etc....)
   end if
end mouseUp

When you click on a button, the mouseUp message is passed through to the
card because no mouseUp handler exists in the button. There the script is
executed. There are probably a dozen ways to do this, but this one is pretty
straight forward and easy.


-Chipp







More information about the use-livecode mailing list