SD Core Solo for Linux LS2.0-0

SD VOC - Using and Managing the VOC

How the command processor reads the VOC, the verbs that manage it, and what account creation puts there.

This page continues SD VOC - Structure and Usage.

How the command processor uses the VOC#

The command processor is a BASIC program, $CPROC, and it runs a loop: show any waiting messages, print the prompt, read a line, dispatch it, repeat. The first word of the line is looked up in the account's voc file.

Name resolution#

A name is tried as typed, then lower case, then upper case (and then with each hyphen changed to a dot, in upper case and in lower case). This is the change that lets a lower-case voc, bp and newvoc on disk coexist with code and habits that still type names in upper case.

Account names are the deliberate exception. They are still folded upward, which is what makes signing in case-insensitive.

If the VOC has nothing, the private vocabulary is tried#

If the account's VOC has a record $private.voc (type X, the name of a file in field 2), a name that is in no VOC record is looked for in that file next, as typed, then in lower case, then in upper case. The VOC always wins, so the private vocabulary can add a command and never replace one the VOC holds. See SD VOC - A Private Vocabulary and Your Own Record Types, which also describes $voc.parser, the record that hands a VOC record of a type SD does not know to a program of your own.

If neither has it, the catalog is tried#

A name that is not in the VOC or the private vocabulary is looked for in the private catalog of the account and then in the global catalog, gcat. A hit is treated exactly as though the VOC had held V / CA / name. This is why a program you have cataloged can be run by typing its name with no VOC record of its own.

If neither has it, the command is refused by name.

Verbs that manage the VOC#

set.file — write a Q-pointer#

set.file account file.name pointer.name

Writes a Q-pointer into the VOC — field 1 Q, field 2 the account name, field 3 the file name. After it, pointer.name is usable wherever a file name is, and the data stays where it is.

The account must be in the accounts register. The name is folded to upper case before the register is read. If it is not there you get Account name '...' is not in register and nothing is written.

update.accounts — refresh from NEWVOC#

update.accounts

Re-runs LOGIN's update.voc paragraph, which copies any changed records from the system NEWVOC into the account's VOC. This is incremental — it re-copies only the records whose stamp has changed, not the whole file. Every ordinary account gets the same NEWVOC now, so update.accounts is only ever bringing an existing account's copy up to date after a release changes something — there is no tier list left for it to consult.

copy — copy records into the VOC#

copy from voc messages,myname
copy from src.file to dict tgt.file record.id

copy can write into the VOC the way it writes into any file. The from voc form copies a VOC record under a new name, which is how an alias is made without alias.

delete — remove a VOC record#

delete voc name

Removes the record. .d name at the command prompt asks first; delete voc name does not.

.s and .r — save and recall#

.s name s e
.r name

.s writes stack lines s to e into the VOC as name — a sentence when the range is one line, a paragraph when it is more. .r loads a sentence or paragraph from the VOC into the stack. The record type follows from what you saved rather than from anything you say. A new record is saved under the name in lower case, however you typed it. A name already in the VOC is found in any case and you are asked "Overwrite VOC record ...?" as before; if you say yes the record keeps the name it has.

Listing the VOC by type#

SD has no ready-made list sentences. (Until 2.0-0 it shipped ten, listf, listfl, listfr, listk, listpa, listph, listq, listr, lists and listv, as R-records into a file called SD.VOCLIB; both are gone.) The query processor does the same job with the type item of the VOC's dictionary:

To list Type it
all files (F-records) list voc with type = "F"
local files only list voc with type = "F" and is.remote = ""
remote files only list voc with type = "F" and is.remote
all keywords (K-records) list voc with type = "K"
all paragraphs (PA-records) list voc with type = "PA"
all phrases (PH-records) list voc with type = "PH"
all Q-pointers list voc with type = "Q"
all remote references (R-records) list voc with type = "R"
all sentences (S-records) list voc with type = "S"
all verbs (V-records) list voc with type = "V"

To see the file type, the description and the data and dictionary pathnames of the files, name those items: list voc ftype desc data.name dict.name with type = "F". The type is DH for a dynamic hashed file (followed by I for alternate key indices, S for statistics and T for a trigger function), Dir for a directory file, Err and the error number for a file that will not open.

The dictionary of the VOC also has the items trigger, encryption and replication, so list voc with type = "F" and with trigger lists the files that have a trigger function. SD has neither encryption nor replication, so with encryption and with replication select nothing, and with no encryption and with no replication select every file.

count — count the records#

count voc
count voc with v = "V"

count over the VOC gives the total record count. With a selection clause it counts by type or by any other field.

ct — display a record#

ct voc name

Displays the record field by field. This is the way to see what a VOC entry actually contains without an editor.

The VOC and the account#

The installer copies the account's VOC from newvoc in the system directory — 441 records. (SDSYS's own VOC, which nobody signs in to, is built from voc_template instead — 446 records, the same verbs plus a few system file pointers.) update.accounts, which needs admin, and an upgrade, add to the account's VOC whatever a new release ships; neither takes anything away.

Administration is in the verb, not in the VOC. Your account has config, set.date, clean.account, list.readu, list.locks, lock, unlock, listu, update.accounts, remote.ssh, remote.api and the rest — and each one refuses with Command requires administrator privileges until admin. There is no create.account, delete.account or modify.account anywhere: an unknown name is simply not recognized. See Administrator commands in the GettingStarted set.

Case on disk#

The VOC ids are stored in lower case — list, create.file and so on. This changes nothing about what you type — SD tries a name as typed, then lower, then upper. What it changes is what SD prints back: CT VOC LIST answers VOC list.

The file-pointer entries — bp, bp.out, gpl.bp, gpl.bp.out — are in lower case. An account's own voc, and the system directory's newvoc, accounts, messages and syscom, are all lower case on disk too. qfile was never a path of its own; it is a VOC pointer to @SDSYS/$ipc, the session IPC area, and has no on-disk name to fold.

What is not here#

There is no verb that edits the VOC directly. ED edits any file, and ED VOCname is how you edit a VOC record by hand. But there is no verb whose purpose is to create or modify VOC entries — set.file writes one kind, .s writes two, and everything else is done with ED or with copy from voc. On SD Core Solo for Linux every direct change to the VOC needs admin — ed voc, a program's write or delete to it, copy into it, .s and .d with a name — and is refused with The VOC can only be changed after admin without it. What SD writes to the VOC itself — create.file's entry, the command stack — is not gated.

PROC is removed. A PQ-type record is refused by name. Nothing that ships is type PQ, so this can only be met in a VOC record somebody wrote.

The M (menu) record type is removed. A VOC record of that type is no longer dispatched; the home screen (home, or menu) is the menu system.

EDIT runs. It is a real V record, the line editor ed under another name (it is not a full-screen editor), not an undispatchable entry of the kind described above. See SD VOC - Structure and Usage.

See also#

SD TCL - The Command Processor · SD TCL - Files and Records · SD Basic - File Handling · SD Basic - Dynamic Arrays.