On Gnu, 2005-06-03 at 10:38 -0500, Tony Mountifield wrote:
>
> I was trying to do something today for which I would have found the
> following construct VERY useful:
>
> $[ expr1 ? expr2 : expr3 ]
>
> which, obviously, would evaluate expr1 as boolean, and return expr2 as
> the expression value if expr1 was true, and return expr3 otherwise.
>
> e.g. SetVar(CLID=$[ $[ ${CLID} : 00 ] ? ${CLID:2} : 44${CLID:1} ])
>
> Or is it already lurking in there and I didn't know?
>
> I had to use a couple of GotoIfs instead.
> Shucks, now I'm kicking myself for not thinking of that myself! Actually, it's lunchtime, had a moment, so I just threw it in. I'll test it out later, and if it works like I'd expect I'll submit a bug+patch and see if anyone else would like this. Maybe they'll incorporate it. I have to take some time and document it properly. The way I set it up, is the test is true if expr1 is a string and not null (or "") , ... and true if a number, and not zero. Depending on the test, expr2 or expr3 are the result, without any forced type conversions. I'll send you a note as to which bug it is, so you track it, if you are interested. murf -- Steve Murphy <[EMAIL PROTECTED]> Electronic Tools Company
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Asterisk-Users mailing list [email protected] http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
