Overview:
Version 4.01 contains an interface to the PLOT+ symbol facility. This offers a variety of tools for manipulating strings. The following are the relevant new commands:
Legal symbol names must begin with a letter and contain only letters, digits, underscores, and dollar signs.
To substitute a symbol within a Ferret command include the name of the in parentheses and preceded by a dollar sign.
For example,
yes? DEFINE SYMBOL hi = hello everyone yes? MESSAGE ($hi) ! issues "hello everyone" msgIt is also possible to nest symbol definitions as the following commands illustrate:
yes? DEFINE SYMBOL label_2 = My test label yes? DEFINE SYMBOL number = 2 yes? SAY ($label_($number)) My test labelBack to Table of Contents
Automatically-generated symbols:
The most obvious usefullness of this is in conjunction with the
symbols that are automatically defined by PLOT+. For example, if we
wish to place a label saying "hello" at the upper right corner of a
plot we might do the following
Use with immediate mode expressions:
When used together with Ferret "immediate mode expressions" (see
below) symbols can be used to perform arithmetic on the plot geometry.
For example, this command will locate the plot title in bold at the
center of a plot regardless of the aspect ratio
Order of string substitutions:
The above example illustrates that the order in which Ferret performs
string substitutions in the command line is significant. The order
of Ferret string substitutions is as follows:
For example, if the script snoopy.jnl contains
Used to customize the position and style of plot labels:
All of the plot labels generated by Ferret are automatically defined
as symbols. This includes the title ($labtit), X and Y axis
labels ($labx),($laby) as well as the positions (latitude,
longitude, depth, time) which are normally placed at the upper left on
a plot.. Sometimes it is desirable to change the location, size or
fonts of these labels. The symbol facility makes it possible to do
this in a way that is independent of the particular label strings or
plot aspect ratio. See the file symbol_demo.jnl for an example.
Used together with command files.
Often in Ferret command files the identical argument substitutions
must be repeated at several points in the file. Using symbols it is
possible to write "cleaner" Ferret scripts in which the argument
substitution occurs only once -- to define a symbol which is used in
place of the argument thereafter. See the file symbol_demo.jnl for
an example.
PLOT+ string editing tools
The PLOT+ program provides a variety of tools for editing symbol
strings. See the PLOT+ Users Guide for further information. A sample
usage:
yes? PLOT/I=1:100 SIN(I/6)
yes? LABEL/NOUSER ($ppl$xlen) ($ppl$ylen) 1 0 .2 hello
This labelling procedure would work regardless of the aspect ratio of
the plot. Use the command "SHOW SYMBOL/ALL" to see the symbols (and
see "General Global Symbols" in the PLOT+ Users Guide).
yes? LABEL/NOUSER `($ppl$xlen)/2` `($ppl$ylen)/2` 0 0 .2 @AC($labtit)
Back to Table of Contents
DEFINE SYMBOL fcn = $1
DEFINE ALIAS ANSWER LIST/NOHEAD/FORMAT=("Result is ",$2)
ANSWER `($fcn)(($3^2)/2)`+5
Then the command
yes? GO snoopy EXP F5.2 2.25
would evaluate to
DEFINE SYMBOL fcn = EXP
DEFINE ALIAS ANSWER LIST/NOHEAD/FORMAT=("Result is ",F5.2)
LIST/NOHEAD/FORMAT=(("Result is ",F5.2) `EXP((2.25^2)/2)`+5
and would result in Ferret output of
Result is 17.57
yes? DEFINE SYMBOL test = my string
yes? PPL SET upper_test $EDIT(test,UPCASE)
yes? SHOW SYMBOL upper_test
UPPER_TEST = "MY STRING"
Back to Table of Contents