[TIP] Sorting by ValueList and synchronized sorting

J. Landman Gay jacque at hyperactivesw.com
Tue Jun 17 20:09:00 EDT 2008


Richard Gaskin wrote:

> It's very handy, but a cognitive hurdle for me at first.  I'd never seen 
> anything like it before.

You probably blocked it. :)

<http://search.gmane.org/?query=custom+sort&group=gmane.comp.ide.revolution.user>

> 
> Anyone else have a mental hiccup when they first encountered this?
> 

All of us. The concept is really snarly, and requires some mental 
gymnastics. And even with the ones I've written myself, I still have to 
figure them out all over again each time I want to use them.

Speaking of mental gymnastics, here's my favorite. I use it a lot. I 
didn't write it, it was written by Tony Root from HyperPro back in the 
day, and turned into a function by Paul Foraker:

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.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list