www.delorie.com/gnu/docs/calc/calc_347.html | search |
Buy the book! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If the first argument to calc-eval
is a list whose first
element is a formula string, then calc-eval
sets all the
various Calc modes to their default values while the formula is
evaluated and formatted. For example, the precision is set to 12
digits, digit grouping is turned off, and the normal language
mode is used.
This same principle applies to the other options discussed below. If the first argument would normally be x, then it can also be the list `(x)' to use the default mode settings.
If there are other elements in the list, they are taken as
variable-name/value pairs which override the default mode
settings. Look at the documentation at the front of the
`calc.el' file to find the names of the Lisp variables for
the various modes. The mode settings are restored to their
original values when calc-eval
is done.
For example, `(calc-eval '("$+$$" calc-internal-prec 8) 'num a b)' computes the sum of two numbers, requiring a numeric result, and using default mode settings except that the precision is 8 instead of the default of 12.
It's usually best to use this form of calc-eval
unless your
program actually considers the interaction with Calc's mode settings
to be a feature. This will avoid all sorts of potential "gotchas";
consider what happens with `(calc-eval "sqrt(2)" 'num)'
when the user has left Calc in symbolic mode or no-simplify mode.
As another example, `(equal (calc-eval '("$<$$") nil a b) "1")'
checks if the number in string a is less than the one in
string b. Without using a list, the integer 1 might
come out in a variety of formats which would be hard to test for
conveniently: "1"
, "8#1"
, "00001"
. (But
see "Predicates" mode, below.)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster donations bookstore | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |