On 2/18/12 7:41 PM, Peter M. Brigham, MD wrote:
I picked this trick up from someone along the way, on this list I
believe, I've lost track of where it came from, so credit goes to
someone else.

It may be from something I posted to the HyperCard list eons ago. I got it from Paul Foraker, who worked on the HC team. He got it from Tony Root, who's the original author. It's been in my script repository ever since, I've used variations on it for years, and every time I use it I *still* have to figure it out all over again. Here are my notes:


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 Foraker writes: ------------

"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. "


--
Jacqueline Landman Gay         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to