I have two lines in my dialplan that I wish to make it into only one, and I fail X.,n(entrada),Set(CALLERID(num)=${CALLERID(num)}0000000000) X.,n,Set(CALLERID(num)=${CALLERID(num):0:11}) It means: add '0000000000' to the caller id, and then take the first 11 chars from the left. It aims to detect null caller ids and replace them by zeros. How can I write this expression in just one line?
Venefax schrieb:> I have two lines in my dialplan that I wish to make it into only one, and I > fail > X.,n(entrada),Set(CALLERID(num)=${CALLERID(num)}0000000000) > X.,n,Set(CALLERID(num)=${CALLERID(num):0:11}) > > It means: add '0000000000' to the caller id, and then take the first 11 > chars from the left. It aims to detect null caller ids and replace them by > zeros. How can I write this expression in just one line?I think it does multiple passes to evaluate ${} so maybe Set(CALLERID(num)=${${CALLERID(num)}0000000000:0:11}) works. However assuming a callerid to always be 11 chars is not generally valid. Gr??e, Philipp Kempgen -- http://www.das-asterisk-buch.de - http://www.the-asterisk-book.com Amooma GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de Gesch?ftsf?hrer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
On Fri, 13 Jun 2008, Venefax wrote:> I have two lines in my dialplan that I wish to make it into only one, and I > fail > X.,n(entrada),Set(CALLERID(num)=${CALLERID(num)}0000000000) > X.,n,Set(CALLERID(num)=${CALLERID(num):0:11}) > > It means: add '0000000000' to the caller id, and then take the first 11 > chars from the left. It aims to detect null caller ids and replace them by > zeros. How can I write this expression in just one line?First, it doesn't do what your explanation says it does. Second, why would you want to? Any savings in execution time will be insignificant and it will obscure the intent and "readability" of the code. FYI, my 2.6GHz P4 executes about 3,000 CALLERID(num) assignments per second. Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
This should do it, but I've not actually tested it. It is based on a line from my own dialplan. _X.,n(entrada),Set(CALLERID(num)=${IF($[${LEN(${CALLERID(num)})} = 0]?0000000000:${CALLERID(num):0:11})}) Venefax wrote:> I have two lines in my dialplan that I wish to make it into only one, and I > fail > X.,n(entrada),Set(CALLERID(num)=${CALLERID(num)}0000000000) > X.,n,Set(CALLERID(num)=${CALLERID(num):0:11}) > > It means: add '0000000000' to the caller id, and then take the first 11 > chars from the left. It aims to detect null caller ids and replace them by > zeros. How can I write this expression in just one line? >-- Consulting for Asterisk, Polycom, Sangoma, Digium, Cisco, LAN, WAN, QoS, T-1, PRI, Frame Relay, Linux, and network design. Based near Birmingham, AL. Now accepting clients worldwide.
Believe it or not, I cannot find online a single piece of documentation for the Asterisk function SPRINTF. This example does not work, for it changes the caller id. Set(CALLERID(num)=${SPRINTF(%010lld,0${CALLERID(num)})}), For instance, if the incoming caller id is 17864335989, I get 0684466805 out of that function, which is not intended one. To be precise, of the caller has less than 10 chars, I want to complete it with a string of '0's. If the caller id is nothing, or empty, I want to replace it with 10 zeroes. I guess I can figure it out if a link to the documentation of SPRINTF is provided.