Operands
The available operands for math commands are:
x Pushes the current value of x onto the stack.
y Pushes the current value of y onto the stack.
z Pushes the current value of z onto the stack.
v Pushes the current value of v onto the stack.
c0 Pushes the line number of the datafile being accessed.
c1 Pushes the current value of the first column in the datafile.
c2 Pushes the current value of the second column in the datafile.
.
.
.
c29 Pushes the current value of the 29th column in the datafile.
c30 Pushes the current value of the 30th column in the datafile.
pi Pushes the number 3.1415927... onto the stack.
e Pushes the number 2.718281828... onto the stack.
add Pops two values from the stack, adds them, and pushes
the result back onto the stack.
sub Pops two values from the stack, subtracts the first
from the second and puts the result back on the stack.
For example, { 3.5 2 sub } results in 1.5 as the top
entry on the stack.
mul Multiplies the top two numbers on the stack and puts the
result on the stack.
div Pops two values from the stack and divides the first
by the second and pushes the result. For example,
{ 6 2 div } results in 3.0 as the top entry on the stack.
set(?) Pops the top number off the stack, and exports it to '?'.
'?' can be one of x, y, z, v, c* (where * ranges from zero
through 50. '?' can also be any variable (e.g. $sum).
There can be no whitespace in the set(?) operand (or any
other operand for that matter).
export This operator is archaic, having been replaced by set(?).
Pops two numbers off the stack, the first is converted
to an integer (must be from -4 to 50) and defines a column
where the second number off the stack is stored. For
example, { 3.1 22 export } results in the value in
column 22 being set to 3.1. Columns 0 through 50 are
the usual data columns. Column -4 is the 'V' data vector.
Column -3 is the 'X' data vector. Column -2 is the 'Y'
data vector. Column -1 is the 'Z' data vector.
exp Pops two numbers off the stack, exponentiates the second
to the power of the first, and stores that value back
onto the stack. For example, { 2 3 exp } results in
the number 8 (2^3) being pushed onto the stack.
mod Pops two numbers off the stack. Pushes the result of
the second modulus the first back onto the stack. For
example, { 24 10 mod } results in 4 as the top entry on
the stack.
min Pops two numbers off the stack and pushes the smaller of
those two onto the stack.
max Pops two numbers off the stack and pushes the larger of
thos two onto the stack.
int Pops the top value off the stack and pushes the integer
part of that value back on the stack.
nint Pops the top value off the stack and pushes the integer
nearest to that value back on the stack.
abs Pops one value from the stack and pushes the absolute
value of that number onto the stack.
neg Pops the top number off the stack, and pushes -1 times
that number onto the stack.
inv Pops the top number, and pushes its reciprocal.
sqr Pops one value from the stack and pushes the square root
of that number onto the stack.
cos Pops one value from the stack and pushes the cosine of
that value onto the stack. The value is assumed to be
in radians.
sin Pops one value from the stack and pushes the sine of
that value onto the stack. The value is assumed to be
in radians.
tan Pops one value from the stack and pushes the tangent of
that value onto the stack. The value is assumed to be
in radians.
dtr Pops one value off the stack, multiplies that value by
pi, divides the result by 180, and pushes this back
onto the stack. In effect, converts Degrees To Radians.
d2r Same as d2r.
rtd Pops one value off the stack, multiplies that value by
180, divides the result by pi, and pushes this back
onto the stack. In effect, converts Radians To Degrees.
r2d Same as rtd.
arccos Pops one value from the stack and pushes the arc-cosine
of that value onto the stack (radians).
arcsin Pops one value from the stack and pushes the arc-sine
of that value onto the stack (radians).
arctan Pops one value from the stack and pushes the arc-tangent
of that value onto the stack (radians).
atan2 Pops two values from the stack, returns the arc-tangent
using both values (therby retaining quadrant information).
log Pops the top value from the stack, and pushes the base 10
logarithm of that number back onto the stack.
ln Pops the top value from the stack, and pushes the natural
logarithm of that number back onto the stack.
leap Pops the top value from the stack, and pushes a 1 onto the
stack if the value is a leap year, and 0 otherwise.
doy Pops three values off the stack ( day-of-month, month, and
year) and pushes the day-of-year back onto the stack. Note
that year is used to calculated leap years. Example;
{ 2000 02 01 DOY } results in a value of 32 as the top entry
on the stack.
mon Pops two entries from the stack (day-of-year and year)
and pushes the month that contains the day of the year
specifiec. For example, { 2000 333 MON } results in a
value of 11 (November).
dom Pops two entries from the stack (day-of-year and year)
and calculates the day-of-month for the current year
and month. For example, { 2000 333 DOM } results in a
value of 28 (the 28th day of November).
pop Pops top number off stack.
flip Exchanges the top two entries on the stack.
dup Duplicates the top entry on the stack.
sav Pops one value from the math stack and pushes it onto
the permanent stack. The permanent stack is a separate
stack that, unlike the math stack, is not cleared at
the beginning of each math command. Hence, sav can be
used to carry forward the result from one math command
to the next.
rec Pops one value from the permanent stack and pushes it
onto the math stack. See sav.
if Pops the top value off the stack. If this number is
else greater than zero, subsequent operators are performed
endif up to the first of either 'else' or 'endif'. If the
top number of the stack is zero, or less than zero,
no operators are performed until the first of 'else'
or 'endif' are encountered. Note that there is no
'elseif' construct. If/else/endif blocks may be nested,
however.
gt Greater than. Pops two numbers off the stack and compares
them. If the number FIRST pushed on the stack is
greater than the top (LAST pushed on the stack) then
1 is pushed on the stack. Otherwise, zero is pushed
onto the stack. For example, { 1 2 gt } results in
zero, while { 2 1 gt } results in 1.
lt Less than.
ge Greater than or equal.
le Less than or equal.
ne Not equal.
eq Equal.
and Performs logical and of top two values.
For example, { 5 3 and } results in 1, while { 5 0 and }
results in 0.
or Logical or.
For example, { 5 0 or } results in 1, while { 0 0 or }
results in 0.
xor Logical exclusive or.
not Logical not.
true Pushes 1.0 on to the stack.
t Same as true.
yes Same as true.
false Pushes 0.0 on to the stack.
f Same as false.
no Same as false.
iand Performs bitwise "and" of top two values on stack
(treated as integers). For example, { 6 3 iand } results
in 2.
ior Performs bitwise "or" of top two values on stack
(treated as integers). For example, { 5 3 ior } results
in 7.
bit I should describe this better. The iand operator is
useful for testing bits, however.
? Same as if.
: Same as else.
> Same as gt.
< Same as lt.
>= Same as ge.
<= Same as le.
<> Same as ne.
== Same as eq.
&& Same as and.
|| Same as or.
& Same as iand.
| Same as ior.
! Same as not.
( Same as noop.
) Same as endif, if an endif is appropriate, otherwise same
as noop.
+ Same as add.
- Same as sub.
* Same as mul.
/ Same as div.
^ Same as exp.
% Same as mod.
noop Does nothing.
err Sets the math-return error flag to the value of the
top entry on the stack. A non-zero value is treated
as an error.
skip Sets the math-return error flag to 1. This has the
effect of causing plotl to skip over a data line during
the reading of the data file.
inc Inclusive test. For example {1 2 4 inc} sets the
math-return error flag to 1 (skips the data) since 1 is
not between 2 and 4. {3 2 4 inc} does not set the
math-return error flag since 3 is between 2 and 4
Typically this operand is used as in:
x={x $xmin $xmax inc}, which is equivalent to, but much
faster than the obsolete syntax x=include($xmin,$xmax).
exc Exclusive test. For example {3 2 4 exc} sets the
math-return error flag to 1 (skips the data) since 3 is
between 2 and 4. {1 2 4 exc} does not set the
math-return error flag since 1 is not between 2 and 4
Typically this operand is used as in:
x={x $xmin $xmax exc}, which is equivalent to, but much
faster than the obsolete syntax x=exclude($xmin,$xmax).
debug Turns on verbose debugging information during stack
math parsing.
dump Writes the contents of the math stack and the permanent
stack to stdout.
exists($var) True if variable "var" exists. False otherwise.
exists(%var) True if character variable "var" exists.
strcmp("string1""string2") True of strings string1 and
string2 exactly match.
xvec X vector value.
yvec Y vector value.
zvec Z vector value.
vvec V vector value.
vectorx Same as xvec.
vectory Same as yvec.
vectorz Same as zvec.
vectorv Same as vvec.
nxai Nearest array or volume x index.
nyai Nearest array or volume y index.
nzai Nearest volume z index.
arrayx Array x position.
arrayy Array y position.
arraydx Array x delta.
arraydy Array y delta.
array Array element.