% -*-LaTeX-*- % TECOQREG.LTX.8, 28-May-86 16:33:25, Edit by BEEBE % This is part of TECO.LTX In order to support local \index{local variables} and \X{global variables}, \TECO{} provides named objects called {\em Q-registers}. These have very simple names which allow the interpreter to find them by fast table lookup, rather than by having to collect a name string and then search a symbol table for it. The names follow one of the functions \begin{flushleft} \begin{tabular}{ll} \TX{G} & get Q-register contents into buffer\\ \TX{:I} & store string value into Q-register\\ \TX{M} & execute \TECO{} code in Q-register\\ \TX{Q} & get numeric value from Q-register\\ \TX{U} & store numeric value into Q-register\\ \TX{X} & store buffer text into Q-register \end{tabular} \end{flushleft} and are a letter or digit preceded by zero, one, or two periods. Letter case does not matter; \T{QA} is the same as \T{qa}. Examples of legal Q-register references are \T{Q0}, \T{Q.0}, \T{Q..0}, and \T{QZ}. Some {\em illegal} references are \T{Q+}, \T{Q...}, and \T{Q*}. The \X{dotted Q-registers} were not present in older \TECO{}'s, but were added to \ETECO{} to provide for commonly-used \X{global variables} which must be rapidly accessible. Their values are normally not changed by \TECO{} programmers if disaster is to be avoided. For example, \ETECO{}'s initialization function is stored in \TX{..L}, and executing it re-initializes the interpreter; if it does not contain valid code, \EMACS{} may crash. In this \TECO{}, the following Q-registers are currently predefined: \begin{flushleft} \begin{tabular}{ll} \TX{..L} & length of last string inserted, or found by search\\ \TX{..R} & last regular-expression search string\\ \TX{..S} & last search string\\ \TX{..T} & temporary storage for coercions\\ \TX{..W} & argument flags\\ \TX{..X} & pre-comma argument\\ \TX{..Y} & post-comma argument\\ \end{tabular} \end{flushleft} They may be read, but should not be modified. \typeout{Remove N from TECO, implement F^XF^Y} Only the undotted Q-registers should be used for local variables. Any which are used by a callable function must be preserved by that function, which is easily achieved by pushing them onto the Q-register stack, and restoring them on return. The function return mechanism will restore them automatically. A Q-register can contain either a string, or a number, and a type code stored with it tells which of the two it is. All Q-registers are initialized to numeric values of 0 when \TECO{} starts up. To allow a program to distinguish between the two possibilities, the function \T{FQq} returns -1 if Q-register \T{q} is a number, and otherwise, it returns the \X{string length}. Thus, if we execute \T{164Uq}, then \T{FQq} returns -1, while \T{:Iqfoo\A{ESC}} followed by \T{FQq} returns 3.