Gri Commands
|
12.45: The `
|
`sprintf \synonym "format" .variable. [.variable. [...]]' |
Write numbers into a synonym (text string). This is useful for labelling plots.
`sprintf \out "a = %lf b = %.2f" .a. .b.
' - Create a synonym
called `\out
', and print the values of the variables `.a.
' and
`.b.
' into it. If `.a.
' = 1 and `.b.
' = 0.112, then
`\out
' will be `"a = 1 b = 0.11"
'
Formatting codes are as in the C programming language, eg:
%.2f -- Use floating point with 2 decimal places. %9.2f -- As above, but number takes 9 characters. %e -- Use exponential notation. |
CAUTION: Variables are stored in the floating point in
Gri, so you must use a format like `"%f"
',
not an integer code like `"%d"
'.