Re: [asterisk-users] Idiot's Question

2008-06-15 Thread Rob Hillis
core show function SPRINTF does work on my 1.4.20 system.

Eric ManxPower Wieling wrote:
 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:
   
 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.
 

   

___
-- 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


Re: [asterisk-users] Idiot's question

2008-06-14 Thread Tilghman Lesher
On Friday 13 June 2008 23:48:24 Fred Posner wrote:
 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]?
 00:${CALLERID(num)})})

For some reason, your post reminded me of how to do it:

Set(CALLERID(num)=${SPRINTF(%010lld,0${CALLERID(num)})})

-- 
Tilghman

___
-- 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


Re: [asterisk-users] Idiot's question

2008-06-14 Thread Eric ManxPower Wieling
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]?00:${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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})
 
 It means: add '00' 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.

___
-- 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


[asterisk-users] Idiot's Question

2008-06-14 Thread Venefax
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.






___
-- 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


Re: [asterisk-users] Idiot's question

2008-06-14 Thread Richard Lyman
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)})}?00:${CALLERID(num)})}

Eric ManxPower Wieling wrote:
 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]?00:${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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})

 It means: add '00' 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?

 


   


___
-- 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


Re: [asterisk-users] Idiot's Question

2008-06-14 Thread Atis Lezdins
On Sat, Jun 14, 2008 at 8:46 PM, Venefax [EMAIL PROTECTED] wrote:
 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,
[EMAIL PROTECTED]
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835

___
-- 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


Re: [asterisk-users] Idiot's Question

2008-06-14 Thread Eric ManxPower Wieling
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:
 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.

___
-- 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


Re: [asterisk-users] Idiot's Question

2008-06-14 Thread Steve Edwards
On Sat, 14 Jun 2008, Venefax wrote:

 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?

 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  [EMAIL PROTECTED]  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


[asterisk-users] Idiot's question

2008-06-13 Thread Venefax
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)}00)
X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})

It means: add '00' 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?


___
-- 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


Re: [asterisk-users] Idiot's question

2008-06-13 Thread Philipp Kempgen
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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})
 
 It means: add '00' 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)}00: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

___
-- 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


Re: [asterisk-users] Idiot's question

2008-06-13 Thread Steve Edwards
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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})

 It means: add '00' 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  [EMAIL PROTECTED]  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


Re: [asterisk-users] Idiot's question

2008-06-13 Thread Steve Edwards
On Sat, 14 Jun 2008, Philipp Kempgen wrote:

 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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})

 It means: add '00' 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)}00:0:11})
 works.

Not in 1.2.

Thanks in advance,

Steve Edwards  [EMAIL PROTECTED]  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


Re: [asterisk-users] Idiot's question

2008-06-13 Thread Fred Posner
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]? 
00:${CALLERID(num)})})


On Jun 13, 2008, at 9:12 PM, Steve Edwards wrote:

 On Sat, 14 Jun 2008, Philipp Kempgen wrote:

 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)}00)
 X.,n,Set(CALLERID(num)=${CALLERID(num):0:11})

 It means: add '00' 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)}00:0:11})
 works.

 Not in 1.2.

 Thanks in advance,
 
 Steve Edwards  [EMAIL PROTECTED]  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



___
-- 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