sprintf

Returns formatted output.

sprintf 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 <inputstr>.

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

Example

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

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

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

See also