mark@hyper.UUCP (Mark Mendel) (11/26/87)
Here are a couple of short, usefull tricks.
1. The q() function: a solution to "& quote &" proliferation
function q
put quote & param(1) & quote into theResult
repeat for i = 2 to the paramCount
put comma & quote & param(i) & quote after theResult
end repeat
return theResult
end q
This little function can shorten your scripts considerably, if you use
the "send" or "do" command at all. Search for "quote" and "comma" in
your scripts and try rewriting the line using q(). For example,
do cmd && quote & arg1 & quote & comma & quote & (v1+v2) & quote
& ",constant"
translates to
do cmd && q(arg1,v1+v2,"constant")
2. Radio button handling.
on radioClick fieldName
-- Each button in a radio button set calls radioClick on mouseUp
-- events. [Not mouseUp, at least Apple does it that way].
-- <fieldName> is the
-- short name of a background field that will always contain the short
-- name of the selected button.
-- the radio buttons should be background buttons.
set the hilite of bkgnd button (field fieldName) to false
set the hilite of the target to true
put value(short name of the target) into field fieldName
end radioClick
on radioInit
-- Usage: radioInit <field>,<button 1>,<button 2>,...,<button n>
-- Call this on openCard events to initilize the buttons.
-- <button 1> will be on for newly created cards.
if field param(1) is empty then put empty into field param(1)
repeat for i = 2 to the paramCount
set the hilite of bkgnd button param(i) to false
end repeat
set the hilite of bkgnd button (field param(1)) to true
end radioInit
The <field> should probably be hidden.
--
Mark G. Mendel, ihnp4!umn-cs!hyper!mark, Network Systems Corporation
(612)-424-4888 x2779