[Asterisk-Dev] Adding set and backref functionality to thefunctionsyntax.

Jerris, Michael MI mjerris at ofllc.com
Wed May 18 00:26:52 MST 2005


> Andreas Sikkema
> 
> Michael Jerris wrote:
> 
> > Examples:
> > 
> > ${IF(${ISNULL(${x=DB(foo/${EXTEN})})}?other:${x})} for setvar 
> > ${IF(${ISNULL(${\x=DB(foo/${EXTEN})})}?other:${\x})} for backref
> 
> Is there a way to add anymore spaghetti to one single line?
> 
> I've written some pretty complicated dialplan stuff, but this 
> is unreadable to anyone but the developer of the code IMHO. 
> Can you explain what is happening here in words, for every 
> language element in these lines?

Sure, if the db entry at foo/extension does not exist (isnull) , return
other, otherwise return the db entry.  

I am not in love with the need for the ${funtionname()} for the
functions but that is another discussion altogether (one that I posted
about 12 hours ago and nobody is yet to answer with something that is
doable without a huge parsing hit).  This proposal simply adds the
ability to set a variable within the ${} block for the function, which
is needed to avoid having to run the function twice in the same line.
Without this functionality:

${IF(${ISNULL(${\x=DB(foo/${EXTEN})})}?other:${\x})} becomes
${IF(${ISNULL(${DB(foo/${EXTEN})})}?other:${DB(foo/${EXTEN})}}.  Which
is definitely worse to read for me, plus has the added issue of the
double db lookup.  And to answer the spagetti comment, this stuff is
very powerful, you could have MUCH more complicated spagetti in a single
line, but at some point it wouldn't be so readable ;)  

Mike

 



More information about the asterisk-dev mailing list