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

12.14: The `get env' Command

`get env \result \environment_variable'

Get the value of an "environment variable" from the unix operating system, and store the result in the indicated synonym. This makes most sense on unix systems (hence the name, patterned after the unix command `getenv'). This command can be useful in making gri programs resistant to changes in data-file locations. Suppose, for example, there is a file called `data', normally in a local directory called `Bravo'. The line `open Bravo/data' will fail if the Bravo directory is moved. But if the name of the datafile is stored in an unix environment variable, `DIR_BRAVO' say, then the gri program will work no matter where the Bravo data are moved, so long as an appropriate environment variable is modified when the data are moved. Example:
get env \dir DIR_BRAVO
if {rpn "\dir" "" ==}
    show "Cannot determine location of the Bravo data,"
    show "which should be stored in the environment"
    show "variable DIR_BRAVO.  You should"
    show "do something like"
    show "export DIR_BRAVO='/data/Bravo/'"
    show "in your ~/.environment file"
    quit

quit end if open \dir/data ...