Difference between revisions of "Format"
m |
|||
| (3 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | __NOTOC__ | |
| − | + | [[Category:Customizations]] | |
| + | {{Global Header}} | ||
| + | {{Global Announcement}} | ||
== Syntax == | == Syntax == | ||
| − | |||
'''string format(string expression, ... variables);''' | '''string format(string expression, ... variables);''' | ||
| − | |||
{| border="1" style="width:200px;" | {| border="1" style="width:200px;" | ||
| Line 15: | Line 15: | ||
| %% | | %% | ||
| percent sign | | percent sign | ||
| + | |- | ||
| + | |%f | ||
| + | |float | ||
|- | |- | ||
| %d | | %d | ||
| Line 23: | Line 26: | ||
|- | |- | ||
|} | |} | ||
| − | |||
| − | |||
'''Example''' | '''Example''' | ||
<source lang="text">format("Change number is %s", chg_ref_num); | <source lang="text">format("Change number is %s", chg_ref_num); | ||
format("Change number is %s and description is %s", chg_ref_num, description);</source> | format("Change number is %s and description is %s", chg_ref_num, description);</source> | ||
| − | |||
| − | |||
== Formatting a UUID as a string == | == Formatting a UUID as a string == | ||
r11.x introduced a new data type known as the UUID which replaced the old integer ID in many areas, most notably with regards to Contacts. This change complicated the printing of the id which previously required only a %d. But since the UUID is not an integer, the %s is now the best solution. | r11.x introduced a new data type known as the UUID which replaced the old integer ID in many areas, most notably with regards to Contacts. This change complicated the printing of the id which previously required only a %d. But since the UUID is not an integer, the %s is now the best solution. | ||
| − | |||
'''Examples'''<source lang="text">string MyResult; | '''Examples'''<source lang="text">string MyResult; | ||
Latest revision as of 13:29, 11 February 2010
To discuss or ask questions about this article, select the discussion tab above.
Syntax
string format(string expression, ... variables);
| Character | Description |
|---|---|
| %% | percent sign |
| %f | float |
| %d | int |
| %s | string |
Example <source lang="text">format("Change number is %s", chg_ref_num); format("Change number is %s and description is %s", chg_ref_num, description);</source>
Formatting a UUID as a string
r11.x introduced a new data type known as the UUID which replaced the old integer ID in many areas, most notably with regards to Contacts. This change complicated the printing of the id which previously required only a %d. But since the UUID is not an integer, the %s is now the best solution.
Examples<source lang="text">string MyResult; MyResult = format( "The uuid of %s is : %s), assignee.userid, (string)assignee.id);
MyResult = format("&{U'%s'=cnt.id->combo_name}", (string)assignee.id);
MyResult = format("&{0x%s=cnt.id->combo_name}", (string)assignee.id);</source>