[asterisk-dev] [Code Review] Add FIELDNUM() function which returns the position number of a field in a list.

Rod Dorman rodd at polylogics.com
Fri Jul 30 11:10:57 CDT 2010


On Thursday, July 29, 2010, 22:03:54, Gareth Palmer wrote:
> On Thu, 2010-07-29 at 15:02 -0500, Tilghman Lesher wrote:
>> On Thursday 29 July 2010 14:51:22 Rod Dorman wrote:
>>> Why not use a -1 to signal an error?
>> 
>> That would be fine, as well, as long as it's documented that way.
>
> The problem have with returning -1 is that constructs like
> GotoIf(${FIELDNUM(...)}?true:false) will take the 'true' path on error.

That could be avoided by testing for greater than zero instead of for
true/false

One thing I'm curious about is if LIST is just "apples" what would
${FIELDNUM(LIST,/,apples)} return?

I would argue that '1' is correct even though the delimiter isn't in
LIST.

-- 
rodd at polylogics.com   "It is better to understand little 
Rod Dorman             than to misunderstand a lot." - Anatole France





More information about the asterisk-dev mailing list