# sprintf2

Returns formatted output.

    sprintf2 strvar FORMAT [ARGUMENT ...]

## Remarks

FORMAT controls the output as in C language printf with ARGUMENTs converted to proper type first. The output string is stored in the string variable <strvar>.

supported format style
type | c, d, i, o, u, x, X, e, E, f, g, G, a, A and s
flags(option) | -, +, 0, # and blank(' ')
width(option) | decimal integer
precision(option) | nonnegative decimal integer(option), preceded by a period(.)

As a result of this command, the system variable "result" is set to one of the following values.

Value | Status
--- | ---
0 | Formatted successfully
1 | No format string
2 | Invalid format
3 | Invalid argument
4 | Invalid destnation variable

## Example

    sprintf2 ver 'Tera Term 4.%d' 51
    messagebox ver 'sprintf test(1)'

    sprintf2 win 'Windows %d (+%s)' 2000 'SP4'
    messagebox win 'sprintf test(2)'

    sprintf2 test '%s=%d %s=0x%x' 'dec' 10 'hex' 33
    messagebox test 'sprintf test macro(3)'

## See also

- "sprintf"