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.4: Complicated example of a new commandThe following example from the global `gri.cmd' file illustrates how to parse/check the commandline (see Local Synonyms), which is a good practice in any code you expect to re-use. The first `if '
statement checks that the word `at ' is in the right place (this
would not have been checked by the syntax matcher, the word having
followed a string). The presence of the keyword `cm ' is checked
for, and user units or cm units are used accordingly. Local variables
are created (`new ') and then destroyed (`delete ') so that
this new command cannot affect outside code.
|