# TCL stack

When a command is entered at the TCL prompt, the system
saves the command in the TCL stack file of the dm account. Your stack
is not terminal dependent. If you leave a terminal without logging
off, another user can use the terminal under your user-ID. This causes
the new user to step-on the stack.

Changing any part of a TCL command in the stack causes that stack entry to be moved to the top of
 the stack. This feature tends to keep the stack compact. The fact that only unique commands are
 saved also helps keep the stack compact. Unique, in this context, means that there are never any
 duplicated commands in the stack. For example, even if the who command had
 been used many times, it only displays once in the stack. Each time a command is found and
 re-executed, it is moved to the top of the stack.

However, the TCL stack does not have a maximum number of entries
and can continue to grow indefinitely. Therefore, from time to time,
the stack should be reduced either from TCL or by using the u (update) command to modify the actual stack item (u dm,tcl-stack, user-ID).

Since the TCL stack is
an updated file, it is frequently locked and updated by the system.
If two users share the same user-ID, then while the first user types
a TCL command, the second user is *locked-out* of the TCL stack,
and their terminal beeps as long as the first user is still entering
the command.

The stacker allows new commands even if the stack
item is locked by another port.

When editing the TCL command stack item, it is possible to cut and paste, and stack data or
 additional commands under the TCL statement. Use the CTRL+V command to stack data or additional
 commands.

These are some of the Update commands that can be used to move through a stack to retrieve and
 run previously entered commands:

| CTRL+A | Searches for the entered string. |
| --- | --- |
| CTRL+D | Returns to the previous command in the stack. |
| CTRL+E | If the cursor is on the first character, deletes the entry from the stack and displays the next command down the stack; otherwise deletes to the end of the command. |
| CTRL+F | Goes forward to the next command up in the stack. |
| CTRL+P | Moves a duplicate copy of the current TCL command at the current position in the stack to the top of the stack. |
| CTRL+X | Clears the displayed command from the screen and moves the pointer back to the top of the stack. |
| CTRL+Z | Returns to the command at the top of the stack. |
| CTRL+ZA | Same as CTRL+A, but searches to the top of the stack. |

## See also

- [stack command](https://d3codex.com/tcl/stack-command/)
- [tcl-stack file](https://d3codex.com/systemfiles/tcl-stack-file/)

---
Source: https://d3codex.com/tcl/tcl-stack/ - part of the D3Codex reference.
