[TIP] Sorting by ValueList and synchronized sorting

Hugh Senior FlexibleLearning at tiscali.co.uk
Wed Jun 18 02:59:55 EDT 2008


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. 




More information about the use-livecode mailing list