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

### 10.11.1: Purpose of newcommands

Gri can be extended easily. Primitive commands (e.g. ``set x name`') can be supplemented with so-called "new commands." New commands are a little like subroutines other programming languages. For example, you might find that you often draw filled curves with a particular graylevel (say 0.5), and then return the graylevel to the previous value. This requires you to do the following each time:

    new .old_graylevel.
    .old_graylevel. = ..graylevel..
    set graylevel 0.5
    draw curve filled to 0 y
    set graylevel .old_graylevel.
    delete .old_graylevel.

This gets a bit tedious, and it would obviously be nicer to just say something like

    Draw my kinda curve

To make this shortcut, you'd tell Gri about the existence of a new command called ``Draw my kinda curve`', and tell it that the new command can be accomplished by the longer code fragment written above.

Once you've learned how to make new commands, you are likely to use them a lot. The following explains how you add new commands. For advice on programming style, etc., (see Resource File).