Returns formatted output.

sprintf FORMAT [ARGUMENT ...]


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 or *
precision(option) nonnegative decimal integer or *(option), preceded by a period(.)

Please specify the floating point number with the string variable and string because the TTL can not support the floating point number.

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


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)'

sprintf 'pi=%f' "3.14159"
messagebox inputstr 'sprintf test macro(4)'

sprintf 'pi=%.4e' "3.14159"
messagebox inputstr 'sprintf test macro(5)'

sprintf 'pi=%.4g' "3.14159"
messagebox inputstr 'sprintf test macro(6)'

See also