[Asterisk-Users] Re: Everyone-- the scoop on Bison/Flex --

Steve Murphy murf at e-tools.com
Fri Jun 3 11:24:45 MST 2005


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 <murf at e-tools.com>
Electronic Tools Company
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3317 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20050603/e5a6fb66/smime.bin


More information about the asterisk-users mailing list