SD Core for Windows WC2.0-0

SD TCL - The Command Stack

Recalling and re-running commands, the @variables, and the session verbs.

This page continues SD TCL - The Command Processor.

The command stack#

Every line you type is kept. The stack is edited with commands beginning with a dot, and n below is a stack position — 1 is the most recent.

.l{n} list the last n stack lines. Defaults to 20, or a screenful
.l name show a VOC record, one numbered line per field
.r{n} recall line n to the top of the stack
.r name load a sentence or paragraph from the VOC into the stack
.s name s e save stack lines s to e into the VOC as name
.a{n} text append text to line n
.i{n} text insert text as line n
.c{n}/old/new/{g} change old to new in line n; g for every occurrence
.d{n} delete line n
.d name delete a sentence or paragraph from the VOC, after asking
.u{n} convert line n to upper case
.x{n} execute line n
.x file id execute a sentence or paragraph held in any file, not just the VOC
.? print this list

n defaults to 1 everywhere, and the spaces shown are required. .d2 deletes the second stack line and .d 2 looks for a VOC record called 2.

.c- undoes the .c just before it. A .l or .? may come between; anything else ends the chance, and .c- then has nothing to undo.

.s and .r together are the whole workflow: type the lines, then save them under a name, then recall them later to edit. .s writes a sentence when the range is one line and a paragraph when it is more, so the record type follows from what you saved rather than from anything you say. A new name is stored in lower case, as every VOC name is; saving over a record that already exists keeps that record's name.

.x file id is the one that reaches outside the VOC — the file name and the record id are each folded as typed, then lower, then upper.

A dot command that is not one of these is not an error. It is left alone and run as an ordinary command, so a verb whose name begins with a dot still works.

.d does not find a lower-case VOC record typed in upper case, and .l and .r do. .l and .r try the name as typed, then lower case, then upper case. .d tries only as typed and then upper case. A paragraph saved as daily can be listed and recalled by typing DAILY and cannot be deleted by typing DAILY. Type the name in the case you saved it in and all three work.

Editing the line you are on#

There are two help texts and they are different. ? on its own prints the key map below; .? prints the dot-command list above. Neither is the help verb, which does not exist — see What is not here.

The key map is the same whether you reached the line by typing it or by recalling it:

Key Also
Ctrl-A start of line Home
Ctrl-E end of line End
Ctrl-B / Ctrl-F back / forward one character Cursor left / right
Ctrl-P / Ctrl-N previous / next command Cursor up / down
Ctrl-Z previous command Cursor up
Ctrl-R reverse search
Ctrl-D delete character Delete
Ctrl-H backspace Backspace
Ctrl-K kill line
Ctrl-O toggle overlay Insert
Ctrl-T transpose characters
Ctrl-U upcase all
Ctrl-G exit the stack

A line ending in ? is put on the stack without being run. That is the way to park a half-written command while you go and look something up.

Saving the stack across sessions#

save.stack {name} write the stack to a named record
get.stack {name} read it back
clear.stack empty it

Both prompt for the name if you leave it off.

@-variables#

set assigns an @-variable, which is then substituted into later command lines wherever its name appears.

set name value
set name eval expression

Without eval the value is taken literally. With eval the text is evaluated first, and the evaluation handles the four arithmetic operators on numeric operands. list.vars shows what is currently set.

The variables the system sets are readable the same way — @system.return.code is the one worth knowing, because most verbs set it and report.src exists to show it.

Session verbs#

who your user number and the account you are in
who.am.i the same information at more length
logto account {reset {all}} change account without logging out; reset restarts the command level, reset all every level
off · quit end the session
option {name} {on|off|display} set or show a session option
option all off turn every session option off at once
alias command target make command run as target
alias command remove that alias
alias list the aliases
clear.abort clear a pending abort condition
set.exit.status n set the numeric status SD exits with
report.src {on|off} show @system.return.code after each command

who answers with your user number and the account you are in:

39 DON

After a logto it grows a third part, and that is the useful one:

29 PAYROLL from DON

from DON is the account you logged in as, not the one you are in and not your Windows account. So the short form means I am still where I started and the long form means I have moved — which makes who the quick way to find out whether a logto actually took effect.

from SDSYS means a session that signed in to Windows as the administrator. Only a session that started in SDSYS can logto sdsys to come back from an account it visited; logto sdsys from any other session is refused outright. Becoming the administrator means signing in to Windows as the sdsys account itself and starting a fresh session — see the Administrator set's Accounts and Security chapter.

logto takes the name of a registered account and nothing else. A name the register does not hold, a pathname included, is refused with "User not allowed in requested account" — the same answer as for an account you may not enter — and the session stays in the account it was in. A directory that should be an account is registered first (create.account other name path) and then entered by its name. An API session's account is chosen the same way.

A suspended account is refused to every session, the administrator's included: "Account name is suspended", and the session stays where it was. This is what signing on to a suspended account has always given everyone. The administrator maintains such an account with run.in and lifts the suspension with modify.account name unsuspended.

logto … reset and logto … reset all#

When a program runs logto with execute, the session is several command levels deep: the prompt, the program's execute, then the execute of the logto itself. The two options say what happens to those levels.

logto account reset restarts the command level the logto ran at, in the new account. The programs that ran the logto carry on when it ends
logto account reset all casts off every level — programs, menus and paragraphs — and runs the new account's login at level 1. Nothing that ran the logto carries on, execute … trapping aborts does not catch it, and the unnamed common blocks of the levels it cast off are gone

At level 1, at the prompt, reset all is reset: there is nothing to cast off. A menu that the new account's login starts is not itself discarded, because the login runs after the levels have gone.

reset all is refused in an API session, with LOGTO RESET ALL is not available in a client session (message 12397), before anything is changed: the API server is its own bottom level and has no prompt to return to.

What is not here#

There is no online help and help is not a verb. The command processor still has internal verb 14 reserved for it and the routine is an empty stub — its body is commented out and it returns immediately. No VOC record points at it, in any account type, so the name is not even recognized. The F1 key at the command prompt reaches the same empty routine and therefore does nothing. This documentation is the help system.

umask is implemented and unreachable. Internal verb 35 is a working routine that reports or sets the file-creation mask, and no VOC record points at it either. It cannot be typed. umask() from SD BASIC still works — see SD Basic - System and Environment.

PROC is removed. So is update.record. A PQ-type VOC record is refused by name rather than being reported as a bad dispatch code, because the record itself is valid PROC and it is the interpreter that is gone. Nothing that ships is type PQ, so this can only be met in a VOC record somebody wrote.

Who has these verbs#

Everything on this page is in a standard account except the last two, which are administrator-only:

standard abort alias clear.abort clear.stack command.logging display get.stack go if list.vars logto off option pause quit report.src save.stack set set.exit.status stop who who.am.i

Everything on this page is in a standard account, and so is command.logging, which is described on SD TCL - The Terminal and the Session: Timers, Dates and Logging. An account that does not have a verb does not have the VOC record for it — the name is simply not recognized rather than refused.

The OS verb is the exception and is not documented here. sh reaches the Windows shell and is gated by a per-account switch. It is in the administrator documentation, under Operating System Access, which is a separate set.

See also#

SD TCL - Files and Records · SD Basic - Program Control · SD Basic - System and Environment.