Format string

See also: variables in strings, string constants and escape sequences



s.format(formatstring ...)
s.formata(formatstring ...)



s - str variable.

formatstring - format-control string.

... - arguments. Variables or other values that will replace format fields in formatstring.



format creates string that can include values of variables. The formatstring consists of ordinary characters that are copied unchanged, and format fields that are replaced with values of arguments.


formata differs from format only that it writes to the end of s (appends).



The mostly used format fields: %i for integer numbers (int, byte, word), %s for strings (str, lpstr), %G for double, %I64i for long, %c for a single character, %X for integers in hexadecimal.

To insert this function, can be used the Text dialog from the floating toolbar.

out and some other functions also support formatting. Example: int i=5; out "i=%i" i



int i=50
str s="stringvar"
double d=3.1415926535897932384626433832795
str f
f.format("variables: i=%i, s=''%s'', d=%.10G" i s d)
out f ;;variables: i=50, s="stringvar", d=3.141592654