s$ = FormatStr(fmt$, ...)
printf
specification. Here is a list of all
tokens that are currently supported:
%c
%d
%i
%d
%o
%u
%x
%X
%e
%E
%e
but in upper case exponential notation
%f
%g
%e
or %f
format (whichever is more compact)
%G
%g
but uses upper case if exponential notation is used
%s
You can also specify a width field before the token to limit the number of
characters that the specific token should add to the string. For example,
if you use the token %.6x
, the hexadecimal number generated by this function
will always have 6 digits.
As the percent sign is used for tokens by this function, you need to escape
it if you just want to append a percent sign to the string. In that case simply
use a double percent sign (%%
).
fmt$
)a = 128 s$ = FormatStr("The number " .. a .. " is $%x in hexadecimal notation", a)The code above converts the number 128 to hexadecimal notation.
a = 255 s$ = FormatStr("The number " .. a .. " is $%.6x in RGB notation", a)The code above converts the number 255 into a 6 digit hexadecimal value which is often used to specify RGB colors.