[asterisk-users] Idiot's Question

Steve Edwards asterisk.org at sedwards.com
Sat Jun 14 13:08:12 CDT 2008


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      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list