_printf
Format and write text to the console
Syntax
_printf(format[, p1[, p2 ... ]])
Parameters
format is a template of the text to be written to the file. It is similar to a C-format string where embedded %s, %d, and %f markers that get replaced by parameters passed to _printf.
p1, p2, ... are the optional parameters to be substituted into the format string.
Returned Value
None
Description
The string format may contain substitution formatting codes:
%d - gets replaced by an integer number.
%D - gets replaced by an integer number that will have commas every 3 digits as in 1,234,567 (as of 3.0.004.05).
%s - gets replaced by a text string.
%S - same as %s except when the data value is a JavaScript structure or array. In these cases, the result is 'prettified' by adding indents and carriage returns (as of 3.1.002.06).
%f - gets replaced by a decimal or floating number.
%F - gets replaced by a decimal or floating number with commas every 3 digits (as of 3.0.004.05).
%x - gets replaced by an integer as a series of hexadecimal digits (lowercase)
%X - gets replaced by an integer as a series of hexadecimal digits (uppercase)
%E - gets replaced by the name of the script event currently being processed. Example: "OnEndMerge" (as of 3.0.004.09).
%% - gets replaced with a single % character.
Between the % and the formatting code, you may add a single number that specifies the character width of the resulting text. For decimal numbers (%f code), you may also specify a format such as %10.4f - where the first number indicates the overall output width and the second the number of digits to display after the decimal point.
Each "%" code must be matched by a parameter p1, p2 etc. The parameter will get converted to the appropriate format and inserted into the output string. There is a reasonable string limitation which can be formatted, about 5000 characters. If a resulting string is too long it gets truncated and appended with "..." in the end. Do not format very long strings, it is not a fast process.
_printf() output is redirected to the Merge log file.Example
_printf("Hello World"); // prints one line to the console
_printf("name=%s, city=%s", "Tony", "Paris"); // prints 'name=Tony, city=Paris'
_printf("value=%4.2f", 3.1415); // prints 'value=3.14'
_printf("value=%4.2F", 12345.67); // prints 'value=12,345.67'
_printf("num=%D", 1234567); // prints 'num=1,234,567'
See Also
fp.fprintf
_logf
_message
_sprintf
_tracef