The Command Stack

The Command Stack

Top  Previous  Next

 

Commands entered at the terminal are stored in a command stack (to be technically correct, it is a queue but historically users have called it a stack). Commands may subsequently be recalled for re-execution by a simple short form command. By default, the stack holds the last 99 commands but this value can be changed by use of the CMDSTACK configuration parameter. The list is indexed by number such that the most recent command is numbered as 1, the oldest as 99. Conventionally, command 1 is referred to as the top of the stack.

 

The stack can be manipulated by commands prefixed by a dot character (period) entered at the command prompt. These allow commands on the stack to be edited and also provide facilities to save and restore sequences of commands to and from VOC paragraphs.

 

The stack manipulation commands are

.An textAppend text to command stack entry n. There must be a space before text. Any additional spaces will be included in the appended data. If n is omitted, the top entry on the stack (position 1) is updated. The text is displayed after modification.
.Cn /old/new/GChange string old to new in stack entry n. If n is omitted, it defaults to one. The delimiters around old and new may be any non-space character. The space before the first delimiter may be omitted if the delimiter is not a digit. The optional G causes a global replacement, that is, all occurrences of old are replaced by new. If G is not specified, only the first occurrence of old is changed. The text is displayed after modification.
.C-Used immediately after .C this undoes the change. An intervening use of .L or .? is permitted. Any other action removes the ability to undo the change.
.DnDelete stack entry n. If n is omitted, the top stack entry is deleted.
.D nameDelete VOC entry name if it is a sentence or paragraph record. A confirmation prompt is issued prior to deletion.
.In textInsert text as stack entry n. If n is not specified, text is inserted at the top of the stack. There must be a space before text. Any additional spaces will form part of the inserted entry.
.LnList the most recent n commands. The value of n defaults to 20. See Command Editor Options.
.L nameList VOC entry name.
.RnRecall stack entry n to the top of the stack without deleting the original copy. If n is omitted, the top entry is duplicated.
.R nameRead VOC entry name to the top of the stack if it is a sentence or paragraph. Field one of the VOC entry is discarded, any continuation lines are merged and blank lines in a paragraph are omitted.
.S name n mSave stack lines m to n as VOC entry name. The value of m and n may be entered in either order. If m is omitted it defaults to the same value as n. If n is also omitted, the top line of the stack is saved. The VOC entry will be a sentence if only a single line is saved, otherwise it will be a paragraph.
.UnConvert stack entry n to upper case. n defaults to one if omitted.
.XnExecute command n. If n is omitted, the last command is executed.

The repeated command is copied to the top of the stack except when executing the current topmost command.

.X file recordExecute command stored in the named file and record. This record must have the same format as a VOC record.
.?Display a help message regarding the stack manipulation commands.

 

For compatibility with other environments, a command can also be saved on the stack without execution by entering it at the command prompt with a question mark as the last character. The question mark is removed.

 

The command stack is saved between sessions if the VOC contains a record named $COMMAND.STACK with field 1 set to X. This record is inserted automatically when a new account is created but can be deleted if the stack is not to be saved. Presence of this record causes the command stack to be saved to, or restored from, a file named as the user's login name in the stacks subdirectory of the account in which QM was entered. On ECS mode systems, the stack is saved in UTF-8 format.

 

QM supports a secondary, private vocabulary file that is represented by a multi-file named PVOC with subfile names that correspond to the uppercase form of the user's login name. The .D, .L, .R and .S commands have an extended form to access the private vocabulary file:

 

.DP nameDelete private vocabulary entry name if it is a sentence or paragraph record. A confirmation prompt is issued prior to deletion.
.LP nameList private vocabulary entry name.
.RP nameRead private vocabulary entry name to the top of the stack if it is a sentence or paragraph. Field one of the entry is discarded, any continuation lines are merged and blank lines in a paragraph are omitted.
.SP name n mSave stack lines m to n as private vocabulary entry name. The value of m and n may be entered in either order. If m is omitted it defaults to the same value as n. If n is also omitted, the top line of the stack is saved. The entry will be a sentence if only a single line is saved, otherwise it will be a paragraph.

 

See also The Command Editor