Next: exp()
Up: MacAnova Help File
Previous: error()
Contents
Usage:
evaluate(cmds), cmds a quoted string or CHARACTER scalar.
|
Keywords:
general, syntax, macros, control
evaluate(Cmds), where Cmds is a quoted string or CHARACTER scalar
consisting of one or more MacAnova commands, executes the commands and
returns the value of the last one. Unlike macro expansion, symbols
starting with '$' in Cmds have no special significance.
As an argument to evaluate(), Cmds is called an "evaluated string".
Cmd> b <- evaluate("a <- PI;sqrt(a)");print(a,b)
a:
(1) 3.1416
b:
(1) 1.7725
In most situations, including the example just given, <<Cmds>> is
equivalent to evaluate(Cmds). See topic 'syntax'.
An evaluated string can contain any MacAnova commands except batch() and
quit() (and its synonyms; see topic 'quitting'). There are also
restrictions on the use of 'break', 'breakall', 'next' and 'return',
'break' and 'next' can be used only to exit or skip to the end of a
loop that was started in the evaluated string.
'return' can be used only to exit a macro that was invoked in the
evaluation string. 'return' cannot be used to exit from the
evaluated string.
'breakall' exits the outermost loop that started in the evaluated
string.
You can use evaluate() recursively, in the sense that evaluate() can be
one of the commands in the evaluated string. The depth D of such a
recursion must satisfy D <= 49 - M, where M is the number of out-of-line
macros currently being evaluated. For example, because there are no
out-of-line macros in use (M = 0), the last value of i printed by
Cmd> i <- 0; cmd <- "i <- i+1;print(i);evaluate(cmd)";evaluate(cmd)
will be 49, followed by an error message.
See also topic 'macros'.
Gary Oehlert
2003-01-15