Previous: Local Values in Macros, Up: Keyboard Macros

17.2.5 Queries in Keyboard Macros

The Z # (calc-kbd-query) command prompts for an algebraic entry which takes its input from the keyboard, even during macro execution. All the normal conventions of algebraic input, including the use of $ characters, are supported. The prompt message itself is taken from the top of the stack, and so must be entered (as a string) before the Z # command. (Recall, as a string it can be entered by pressing the " key and will appear as a vector when it is put on the stack. The prompt message is only put on the stack to provide a prompt for the Z # command; it will not play any role in any subsequent calculations.) This command allows your keyboard macros to accept numbers or formulas as interactive input.

As an example, 2 <RET> "Power: " <RET> Z # 3 <RET> ^ will prompt for input with “Power: ” in the minibuffer, then return 2 to the provided power. (The response to the prompt that's given, 3 in this example, will not be part of the macro.)

See Keyboard Macro Query, for a description of C-x q (kbd-macro-query), the standard Emacs way to accept keyboard input during a keyboard macro. In particular, you can use C-x q to enter a recursive edit, which allows the user to perform any Calculator operations interactively before pressing C-M-c to return control to the keyboard macro.