VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
venefax at gmail.com Guest
|
Posted: Fri Jun 13, 2008 7:08 pm Post subject: [asterisk-users] Idiot's question |
|
|
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? |
|
Back to top |
|
|
philipp.kempgen at amo... Guest
|
Posted: Fri Jun 13, 2008 7:52 pm Post subject: [asterisk-users] Idiot's question |
|
|
Venefax schrieb:
Quote: | 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 |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Fri Jun 13, 2008 7:59 pm Post subject: [asterisk-users] Idiot's question |
|
|
On Fri, 13 Jun 2008, Venefax wrote:
Quote: | 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 |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Fri Jun 13, 2008 8:12 pm Post subject: [asterisk-users] Idiot's question |
|
|
On Sat, 14 Jun 2008, Philipp Kempgen wrote:
Quote: | Venefax schrieb:
Quote: | 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.
|
Not in 1.2.
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000 |
|
Back to top |
|
|
fred at teamforrest.com Guest
|
Posted: Fri Jun 13, 2008 11:48 pm Post subject: [asterisk-users] Idiot's question |
|
|
You could always do something like this, but I think it may pull more
proc than on 2 lines:
exten => s,n,Set(CALLERID(num)=${IF($["foo${CALLERID(num)}" = "foo"]?
0000000000:${CALLERID(num)})})
On Jun 13, 2008, at 9:12 PM, Steve Edwards wrote:
Quote: | On Sat, 14 Jun 2008, Philipp Kempgen wrote:
Quote: | Venefax schrieb:
Quote: | 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.
|
Not in 1.2.
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867
PST
Newline Fax:
+1-760-731-3000
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
|
|
|
Back to top |
|
|
tilghman at mail.jeffa... Guest
|
Posted: Sat Jun 14, 2008 7:38 am Post subject: [asterisk-users] Idiot's question |
|
|
On Friday 13 June 2008 23:48:24 Fred Posner wrote:
Quote: | You could always do something like this, but I think it may pull more
proc than on 2 lines:
exten => s,n,Set(CALLERID(num)=${IF($["foo${CALLERID(num)}" = "foo"]?
0000000000:${CALLERID(num)})})
|
For some reason, your post reminded me of how to do it:
Set(CALLERID(num)=${SPRINTF(%010lld,0${CALLERID(num)})})
--
Tilghman |
|
Back to top |
|
|
eric at fnords.org Guest
|
Posted: Sat Jun 14, 2008 12:16 pm Post subject: [asterisk-users] Idiot's question |
|
|
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:
Quote: | 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. |
|
Back to top |
|
|
venefax at gmail.com Guest
|
Posted: Sat Jun 14, 2008 12:46 pm Post subject: [asterisk-users] Idiot's Question |
|
|
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. |
|
Back to top |
|
|
pchammer at dynx.net Guest
|
Posted: Sat Jun 14, 2008 12:58 pm Post subject: [asterisk-users] Idiot's question |
|
|
TP'n to follow flow.
I haven't seen anyone mention ISNULL so there is an example (obviously
wrap it in the below Set(CALLERID(num)=...) as the other examples are)
${IF(${ISNULL(${CALLERID(num)})}?0000000000:${CALLERID(num)})}
Eric "ManxPower" Wieling wrote:
Quote: | 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:
Quote: | 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?
|
|
|
|
Back to top |
|
|
atis at iq-labs.net Guest
|
Posted: Sat Jun 14, 2008 12:59 pm Post subject: [asterisk-users] Idiot's Question |
|
|
On Sat, Jun 14, 2008 at 8:46 PM, Venefax <venefax at gmail.com> wrote:
Quote: | 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.
|
Well, 10 chars or 4294967296 to be precise is the limit of integer, so
on 32 bit platform this won't work. Just do the string processing
Btw - some kind of str_pad function in dialplan would be nice
Regards,
Atis
--
Atis Lezdins,
VoIP Project Manager / Developer,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835 |
|
Back to top |
|
|
eric at fnords.org Guest
|
Posted: Sat Jun 14, 2008 1:03 pm Post subject: [asterisk-users] Idiot's Question |
|
|
Oddly "core show function SPRINTF" works on my 1.6. SPRINTF function
does not seem to be in 1.2 and I don't have any 1.4 systems.
Venefax wrote:
Quote: | 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.
|
--
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. |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Sat Jun 14, 2008 1:08 pm Post subject: [asterisk-users] Idiot's Question |
|
|
On Sat, 14 Jun 2008, Venefax wrote:
Quote: | Believe it or not, I cannot find online a single piece of documentation for
the Asterisk function SPRINTF.
|
Wasn't "googling" for "asterisk function sprintf" productive?
Quote: | 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.
|
SPRINTF is not in 1.2
This is obtuse. Unless the guy modifying your dialplan 5 years from now is
a reasonably advanced C programmer, he will have no clue what you were
trying to accomplish.
Aside from not handling the null case correctly, your original 2 line code
was "better." Making your dialplan maintainable is more important than
potentially shaving a fraction of a millisecond off the execution time.
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000 |
|
Back to top |
|
|
rob at hillis.dyndns.org Guest
|
Posted: Sun Jun 15, 2008 3:01 am Post subject: [asterisk-users] Idiot's Question |
|
|
core show function SPRINTF does work on my 1.4.20 system.
Eric "ManxPower" Wieling wrote:
Quote: | Oddly "core show function SPRINTF" works on my 1.6. SPRINTF function
does not seem to be in 1.2 and I don't have any 1.4 systems.
Venefax wrote:
Quote: | 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.
|
|
|
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|