navigation map

Chapters:
  1: Introduction
  2: Simple example
  3: Invocation
  4: Finer Control
  5: X-Y Plots
  6: Contour Plots
  7: Image Plots
  8: Examples
  9: Gri Commands
  10: Programming
  11: Environment
  12: Emacs Mode
  13: History
  14: Installation
  15: Gri Bugs
  16: Test Suite
  17: Gri in Press
  18: Acknowledgments
  19: License

Indices:
  Concepts
  Commands
  Variables
index.html#Top ListOfGriCommands.html#ListOfGriCommands Gri: `source' command Gri: `state' command index.html#Top Gri: `state' command

9.3.47: `sprintf'


`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"'. If you want an integer, use `"%.0f"'.

navigation map