Go to the previous, next section.
A plot macro is a set of commands that you can execute together by invoking the name of the macro; in effect, it is a plot subroutine. For example, suppose you had a set of plots that you wanted to generate, using the same type of axis box and labels. Rather than laboriously typing the box and label and limits commands for each set of data, you could define a macro as follows:
drawbox # this is a comment
limits 0 20 0 100
box
xlabel xdata
ylabel ydata
where the macro name in this example is drawbox. Then, when you
access your data, you could do as follows:
data file1.dat
read { x 1 y 2 2
drawbox
connect x y
data file2.dat
read x 3
read y 7
drawbox
connect x y
(The read { x 1 y 2 2 is the same as read x 1 read y 2, but
faster).
This is a simple-minded example, and you can immediately see ways to
improve the macro I have created to save even more typing. Macros may
consist of any SM commands, and may have arguments. You
specify the number of arguments in the macro definition, and refer to
them by number, preceded by $. In the example I gave above, suppose
we wanted to make the axis labels into variables. Then the macro
definition would look like this:
drawbox 2 # this is also a comment
limits 0 20 0 100
box
xlabel $1
ylabel $2
Then to invoke the macro, I type
drawbox xdata ydata
You can make a macro in 4 ways:
macro read command
macro read macro.file
will read all the macros
in the file macro.file.
macro mname 1 20
will extract lines 1 through 20 from the history
buffer, and create the macro mname which consists of those 20
lines.
macro command
macro mname {
will start the definition of the macro named mname. You then enter
SM commands, and terminate the macro definition with a closing
}.
macro edit command
macro edit mname
will invoke the macro editor, and you can then enter SM
commands to define the macro. The editor is described in detail in
the SM manual; the main commands to remember are as follows:
In the following descriptions ^X means hold down the CTRL key and
then press the X key
Go to the previous, next section.