To output formatted strings use the routines DiagnosticOutput, WarningOutput, CriticalOutput, DebugOutput, OutputWithFlags, FormatString and FormatCString.
They use the following syntax:
"@" is the placeholder for any parameter. Formatting details are optional and can follow using curly brackets. "@@" is the placeholder for the actual @ character. To use a format string that has two placeholders directly behind one another use "@{}@"
As a parameter you can use any datatype that has ToString() defined. By default this is any integral data type, String, CString, Url, Data, Container, Id, BaseArray, BlockArray, PointerArray, SortedArray, HashMap, TimeValue etc.
Call | Output | Comment |
DiagnosticOutput("@");
| @
| If there is only one parameter no formatting takes place! |
@5
| The first @ results in the actual character. | |
52
| {} inbetween defines two parameters directly after another instead of the @ character. |
Call | Output | Comment |
97
| Regular number output. | |
97
| Independent of the input width the actual number value is printed. | |
a
| 'c' is the formatting statement for character. | |
__-97
| Five characters are printed. To visualize this a '_' is shown instead of a whitespace. | |
-9700
| If not enough characters are provided the full number is still printed. | |
EE-97
| A fill character has been provided. | |
Note that 'Int' results in 16 characters for a 64-bit compile and 8 characters for a 32-bit compile. | ||
0000005F
| Like the example before, but with uppercase letters. | |
Like before, but no leading zeros are printed. | ||
F
| Like before, but with uppercase letters. | |
00bd
| Default case with leading zeros | |
00bd
| Same as above but the fillspace is somewhat useless since the unused digits of a number are always filled with leading zeros. | |
0x00bd
| Default case with additional string to show that the output is of hex format. | |
____00bd
| Eight characters are printed. To visualize this a '_' is shown instead of a whitespace. | |
~~~~00bd
| Int16 value is converted to a 4 byte value with leading zeros, the rest is filled with fill chars. | |
bd
| Default case without leading zeros. | |
bd
| Same as above but fill char is ignored since the output is always only the minimum digits needed. | |
______bd
| Eight characters are printed. To visualize this a '_' is shown instead of a whitespace. | |
~~~~~~bd
| Eight characters are printed. Unused digits are filled with the fill char | |
1.28 MiB
| The memory unit is chosen dynamically. |
Call | Output | Comment |
-4354.3
| By default up to 3 digits after the comma are printed. | |
~~~-4354.3
| 8 characters before comma by using a fill char. | |
-4.32400
| 5 digits after the comma will be printed. | |
-4.324
| Up to 5 digits after the comma will be printed. | |
-0.003333333333333334
| If Float has only single precision, the number of digits will be less. |
Call | Output | Comment |
TimeValue t = Milliseconds(45.254); DiagnosticOutput("@", t);
| 45.3 ms
| By default up to 1 digit after the comma is printed. |
TimeValue t = Milliseconds(45.254); DiagnosticOutput("@{8.3'%'}", t);
| %%%%%%45.254 ms
| Fill chars and format rules work like for regular float values. |
TimeValue t = Milliseconds(45.254); DiagnosticOutput("@{s.3}", t);
| An output unit can be specified. It must be the first parameter of the formatting string. |
Call | Output | Comment |
00000004
| Note that either 8 or 16 characters are printed depending on if this is a 32-bit or 64-bit build. | |
0x00000004
| As before with 0x manually added. | |
0x4
| As before but without leading zeros. | |
15
| If the pointer is not void the content is printed. |
If you want to output types like Data, DataContainer, HashMap<..., Data> etc. the problem is that each data type may support a different syntax. E.g. a formatting statement ".1" is valid for a float, but not valid for an integer. To solve this problem you can address the type that the statement was made for.
The syntax is:
Possible types are "float", "int", "timer" or further custom enhancements of your data types.
Call | Output |
DataContainer bc;
bc.Set(1000, Data((Int64)5);
bc.Set(1001, Data(Vector64(4.0));
DiagnosticOutput("@{float:.6|int:8'o'}", bc);
|