Next: , Previous: , Up: Calculator Internals   [Contents][Index]

17.6.7.2 Interactive Functions

The functions described here are used in implementing interactive Calc commands. Note that this list is not exhaustive! If there is an existing command that behaves similarly to the one you want to define, you may find helpful tricks by checking the source code for that command.

Function: calc-set-command-flag flag

Set the command flag flag. This is generally a Lisp symbol, but may in fact be anything. The effect is to add flag to the list stored in the variable calc-command-flags, unless it is already there. See Defining New Simple Commands.

Function: calc-clear-command-flag flag

If flag appears among the list of currently-set command flags, remove it from that list.

Function: calc-record-undo rec

Add the “undo record” rec to the list of steps to take if the current operation should need to be undone. Stack push and pop functions automatically call calc-record-undo, so the kinds of undo records you might need to create take the form ‘(set sym value)’, which says that the Lisp variable sym was changed and had previously contained value; ‘(store var value)’ which says that the Calc variable var (a string which is the name of the symbol that contains the variable’s value) was stored and its previous value was value (either a Calc data object, or nil if the variable was previously void); or ‘(eval undo redo args …)’, which means that to undo requires calling the function ‘(undo args …)’ and, if the undo is later redone, calling ‘(redo args …)’.

Function: calc-record-why msg args

Record the error or warning message msg, which is normally a string. This message will be replayed if the user types w (calc-why); if the message string begins with a ‘*’, it is considered important enough to display even if the user doesn’t type w. If one or more args are present, the displayed message will be of the form, ‘msg: arg1, arg2, …’, where the arguments are formatted on the assumption that they are either strings or Calc objects of some sort. If msg is a symbol, it is the name of a Calc predicate (such as integerp or numvecp) which the arguments did not satisfy; it is expanded to a suitable string such as “Expected an integer.” The reject-arg function calls calc-record-why automatically; see Predicates.

Function: calc-is-inverse

This predicate returns true if the current command is inverse, i.e., if the Inverse (I key) flag was set.

Function: calc-is-hyperbolic

This predicate is the analogous function for the H key.

Next: Stack-Oriented Functions, Previous: Data Type Formats, Up: Calculator Internals   [Contents][Index]