Programming Gri
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
|
5: Programming in the Gri Language
The Gri programming language has `if ' statements to control program
flow, and a `while ' statement to repeat commands. There are two
data types in Gri: ``variables'' (to store numbers) and ``synonyms'' (to
store character strings). Gri recognizes commands by matching
statements against its list of known commands. This list is extensible;
it is easy to add new commands as extensions to Gri.
5.1: Online Help
Type `help ' to get a list of available commands and other topics of
interest. Here's how Gri responds
Type `help' followed by a command-name:
cd close convert create
debug delete differentiate draw
expecting filter flip get
help if ignore input
insert interpolate list ls
mask move new open
pwd query quit read
regress reorder rescale resize
return rewind set show
skip smooth sprintf state
superuser system write
Or type `help -' followed by a topic in:
example extending files math
strings synonyms variables manual
|
Some commands have more words than shown. You can type these additional
words to narrow the help down; otherwise Gri will give you help
on all commands that begin with the indicated words. For example, try
`help set ' and `help set x '. When you ask for help on a
multi-word command, Gri tells you about all commands which begin
with the words you've typed. Thus,
help
help draw
help draw zero
help draw zero line
|
narrow in on the command `draw zero line '. The response to the
most complete request is:
`draw zero line [horizontally|vertically]'
draw zero line
Draw line y=0 if it's within axes
draw zero line horizontally
Draw line y=0 if it's within axes
draw zero line vertically
Draw line x=0 if it's within axes
|
The part enclosed in angled quotes is the syntactical description of the
command. (NOTE: The square brackets indicate an optional word (in this
case) or words. The vertical bar indicates that either the item on the
left or the item on the right may appear; it is a logical OR operator.
The only other special characters in syntax descriptions are the braces
`{} ', which are used to enclose multiple words which act as one
unit; they are used to clarify the choices presented to the OR
operator.) Following the syntactical description are examples. Each
example is indented 2 spaces, and a description of it (which always
starts with an upper-case character and ends with a period, to indicate
that it's an English description) follows that, indented by an
additional 2 spaces.
5.2: Command Lines
To extend a command across several lines, use a backslash `\\ ' at
the very end of all lines but the last:
draw line from \
10 20 \
to \
10 30
|
|