Sunday, April 02, 2006

Allen Ormond's eop command

Allen just created a fantastic command called eop that makes it easy to create those commands that go to different URLs depending on whether or not a parameter is given (example). The beauty part is that he fashioned it entirely out of existing YubNub commands. It is truly a work of art (and as with many commands, I haven't yet fully grokked how it works). Check it out:

ifthen -value1 {strfind -find ${token=@}${token=@} -string %s} -value2 0 -test equal -then {strreplace -find ${token=@} -replace -string %s} -else ${else}

It's as elegant (and impenetrable :-) as a terse regular expression.

3 Comments:

Anonymous Anonymous said...

This is a fantastic command! Allen has made many very interesting commands lately!

4/02/2006 4:14 p.m.  
Anonymous Anonymous said...

Thanks for the mention and the GE!

For the curious, here's how the command works:
It doesn't really check to see if the value between the tokens is empty, what it's really doing is searching the string for two tokens side-by-side (@@) using strFind. If found, that means that the value is empty because otherwise they'd be seperated by the value.

So, if @@ is not found in the string, the tokens are stripped from the string using strReplace and the string is returned. If @@ IS found, then nothing is returned (or -else if it's set).

4/02/2006 4:46 p.m.  
Blogger Jonathan said...

Clever!

4/02/2006 7:17 p.m.  

Post a Comment

<< Home