[Home]

Summary:ASTERISK-06892: [patch] SPRINTF dialplan function
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2006-05-04 00:04:34Date Closed:2006-05-17 19:01:19
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Functions/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20060505__sprintf_dialplan_function.diff.txt
Description:Replicates the functionality of SPRINTF in the dialplan, doing necessary conversions on each argument before formatting the output.
Comments:By: Terry Wilson (twilson) 2006-05-05 12:46:15

Tested.  Works for me.  Might include an example in the usage for left/right padding or something since the average user may not be wading through man 3 sprintf (that part of the man page is a bit obtuse).

SPRINTF(:%10s:|hello) results in   :     hello:
SPRINTF(:%-10s:|hello) results in :hello     :

or something like that.  I messed up at first since I am used to coding printf(":%10s:", var) with a comma and a space, I started seeing leading spaces when I did SPRINTF(%s, hello).  Fun.  :-)  Like the patch and will be very useful for me.  Thanks.

By: Tilghman Lesher (tilghman) 2006-05-05 13:01:35

There is one other form that you may find useful, and that is:
SPRINTF(%-10.10s|somethingreallylong) which results in "somethingr"

This is useful for fixed width fields.  The same specification
works for shorter fields, too:
SPRINTF(%-10.10s|foo) which results in "foo       ".

By: Joshua C. Colp (jcolp) 2006-05-17 19:01:18

Added to trunk as of revision 28016! Thankies!