sprintf2

Returns formatted output. (version 4.62 or later)

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

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