top banner
Gri Commands
1: Introduction
2: Simple example
3: Fancy example
4: Running Gri
5: Programming Gri
6: General Issues
7: X-Y Plots
8: Contour Plots
9: Image Plots
10: Examples
11: Handling Data
12: Gri Commands
13: Gri Extras
14: Evolution of Gri
15: Installing Gri
16: Gri Bugs
17: System Tools
18: Acknowledgments
19: License
20: Newsgroup

21: Concept Index
navigate navigate navigate navigate navigate navigate

12.25: The `new' Command

new .variable_name. | \synonym_name \
  [.variable_name. | \synonym_name \
    [...]]
Set 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
bottom banner