navigation map

  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

index.html#Top ListOfGriCommands.html#ListOfGriCommands Gri: `mask' command Gri: `newpage' command index.html#Top Gri: `newpage' command

9.3.25: `new'

new .variable_name. | \synonym_name \
   [.variable_name. | \synonym_name \

`new' sets aside storage for new version of the named variable(s) and/or synonym(s). Any number of variables and synonyms may be specified. If a given variable/synonym already exists, this will create a new version of it, and future assignments will be stored in this new version without affecting the pre-existing version. If the variable/synonym is `delete'ed, the new version is deleted, making the old, unaltered, version accessible again.

This command is used mostly for temporary use, to prevent clashing with existing values. Suppose you want to change the font size inside a new command or an if block. Then you might do the following, where the variable `.tmp.' is used to store the old font size. Note that the use of the `new/delete' statements prevents the assignment to the local version of the variable `.tmp.' from affecting the value known outside the `if' block, if in fact `.tmp.' happened to exist outside the block.

set font size 10
draw label "This is in fontsize 10" at 10 2 cm
if .want_title.
  new .tmp.
  .tmp. = ..fontsize..
  set font size 22
  draw label "This is 22 font" at 10 5 cm
  set font size .tmp.
  delete .tmp.
end if
draw label "This is 10 font" at 10 8 cm

Special case: for local synonyms (e.g. `\.word1.', etc.), the `new' operator checks to see whether the synonym is standing for an "ampersand" argument, signalling a changeable argument that is a variable or a synonym. In such a case, `new' creates a new instance of the item in the calling context. The test suite has examples (see Test Suite).

navigation map