[asterisk-users] Stripping characters from ${CALLERID(num)} ?

Bryant Zimmerman BryantZ at zktech.com
Thu Jul 7 15:22:06 CDT 2011


----------------------------------------
 From: "Bryant Zimmerman" <BryantZ at zktech.com>
Sent: Thursday, July 07, 2011 4:14 PM
To: "Asterisk Users Mailing List - Non-Commercial Discussion" 
<asterisk-users at lists.digium.com>
Subject: Re: [asterisk-users] Stripping characters from ${CALLERID(num)} ?

Here is a simple way to strip the '-' 

Here is a concept solution.
I have not tested the code so there may be some syntax errors. 
It can work as I am doing stuff like this all the time. This example is 
using a check to only do the cut if there is more than one field. You may 
be able to just use step 3 from ctx and have what you want, but I am not 
sure if it will fall back gracefully if there is only 1 field. 

No AGI required.

exten => mycode,n,Gosub(ctx,1)

exten => ctx,1,Set(l_filedCNT=${FIELDQTY(CALLERID(num),-)})
exten => ctx,n,GotoIf($[${MATH(${l_filedCNT}>1)}=TRUE]?DoStrip:doSkip)
exten => ctx,n(doStrip),Set (CALLERID(num)=${CUT(CALLERID(num), -, 1-)})
exten => ctx,n(doSkip),NoOp(${CALLERID(num)})

Thanks
zktech

Made a correct in the above to reflect the skip state doSkip vs SkpStrip 
and made syntax correct to the Set/CUT line. There may still be a few more 
syntax issues in there.

zktech


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110707/2a3eb3e6/attachment.htm>


More information about the asterisk-users mailing list