This is very elegant. With a little more tweaking, you could use it to choose any of more than 2 values! Now in the Scripter's Scrapbook.

Thank you, Jacque.

/H


J. Landman Gay wrote:
function whichOne var,fld1,fld2  -- from a handler by Tony Root
-- Handles a case where you need to return one value if your key is
empty, another if not.

  return (item offset(char 1 of (var = empty),"tf") of quote & fld1
&","& fld2 & quote)
end whichOne

Paul says:

"There's a great scripter working at Digital Pictures named Tony Root,
who wrote a one-line boolean evaluator that I corrupted into a function.
This handles the case where you need to return one value if your key is
empty, another if not. For example, if the social security number field
(var) is empty, then return "Please fill in your social security number"
(fld1); otherwise, return "Now please fill in the form on the next
page." (fld2). The elegant part (which Tony wrote) is getting the offset
of char 1 of an expression that resolves to true or false, of "tf". Wish
I'd thought of that. "

You don't have to use it for just empty/not empty. With some
adjustments, you can use it to choose between any two values.
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to