EVAL - evaluate arithmetic and logical expressions.
Syntax:
EVAL expression [expression]*
Examples:
eval 3+3 4**2 "xxx"+"yyy"
eval sin( 90.0 / (360.0/(2*pi)))
Description:
EVAL displays the value of each expression, separated by
spaces. EVAL expressions take the same form as expressions in the
TSS IF command.
An "_" in any expression represents the value of the
previous expression. For example,
eval 3+3 _
displays
6 6
As with IF, EVAL keeps the value of "_" in the UST
core file for subsequent use by later EVAL or IF commands.
EVAL lets you redirect its output using the normal
">file" and ">>file" constructions.
However, to avoid confusion with expressions that use
">" or ">>" as operators, the
following rules apply:
- A redirection may only appear on the command line as the
first argument (after the command name EVAL) or as the
last argument. Putting the redirection first is
preferred, since this syntax cannot be confused with
valid expressions. If a ">name" or
">>name" construct appears elsewhere on
the command line, EVAL assumes it is part of an
expression.
- A redirection construct must have a space before the
">" or ">>". If the
redirection is the first argument, it must also have a
space after the filename. If there is a space immediately
after the ">" or ">>", the
construct is assumed to be part of an expression rather
than a redirection construct. To be on the safe side, it
is a good idea to put a space after ">" or
">>" whenever they are used as operators.
- If a construct has the form ">something" or
">>something" and is in the right place
on the command line, the construct is assumed to be a
redirection. EVAL tries to open "something" as
an output file name; if this fails because
"something" doesn't have the proper syntax to
be a pathname, EVAL then assumes the string was part of
an expression after all and attempts to evaluate it as an
expression.
- If "something" has the syntax of a pathname but
there is some other reason why it can't be opened, EVAL
terminates with an appropriate error message.
These rules do not avoid all ambiguity. For example, in an
expression like
eval 3+5 >4/2
the "4/2" is assumed to be a file named
"2" under a userid named "4". This will
probably fail unless your site really has a userid named
"4". Such situations seldom occur. If you do not want
"4/2" to be taken as a filename, put a space after the
">", as in
eval 3+5 > 4/2
See Also:
expl if
Copyright © 1996, Thinkage Ltd.