SD Core Solo for Linux LS2.0-0

SD VOC - A Private Vocabulary and Your Own Record Types

The two optional VOC records $private.voc and $voc.parser: where SD looks for a command that the VOC does not hold, and what it does with a VOC record whose type it does not know.

This page continues SD VOC - Using and Managing the VOC. Both records described here are ordinary VOC records of type X, and neither is in a stock VOC: an account has them only if somebody wrote them. SD reads $private.voc each time it looks up a command, and $voc.parser once, when the session signs on.

SD folds case, so a command may be typed in either case. Commands are shown here in lower case. In the tables, italics mark something you supply.

The names zzpv, zzhello and the like are only examples. What differs on SD Core Solo for Linux from SD Core for Linux, the multi-user product, is who may write the two records, and that is the last section.

Where a command is looked for#

The first word of a line is the command. The command processor looks for it in this order, and stops at the first place that has it:

  1. The account's VOC. The word as typed, then in lower case, then in upper case, then with each hyphen changed to a dot (lower case, then upper case): zz-vdot finds a VOC record called zz.vdot.
  2. The private vocabulary, if the VOC has $private.voc. The word as typed, then in lower case, then in upper case. There is no hyphen form here: zz-dot does not find a private record called zz.dot.
  3. The private catalog and then the global one, as page 32a describes.
  4. Otherwise xx is not in your VOC.

So the private vocabulary is searched only for a word that is in no VOC record, and it is searched before the catalog.

$private.voc: a second vocabulary in a file of your own#

001  X
002  filename

Field 1 is X (a capital or a small x; anything after the first letter is a comment). Field 2 is the name of a file, and the file is laid out as the VOC is: each record's id is a command word and its contents are a VOC record of any type. A verb, a sentence and a paragraph all work.

:create.file zzpv

A program that makes the file, puts three records in it and points the VOC at it (the writes to the VOC need admin on Solo, described under Who can make them, below):

open 'zzpv' to f else stop
write 'PA':@fm:'display paragraph from the private vocabulary' on f, 'zzhello'
write 'S':@fm:'display sentence from the private vocabulary' on f, 'zzsent'
write 'PA':@fm:'display private vocabulary copy' on f, 'zzdup'
open 'voc' to v else stop
write 'PA':@fm:'display the VOC copy of zzdup' on v, 'zzdup'
write 'X':@fm:'zzpv' on v, '$private.voc'

Before the $private.voc record is written:

:zzhello
zzhello is not in your VOC

After it:

:zzhello
paragraph from the private vocabulary
:ZZHELLO
paragraph from the private vocabulary
:zzsent
sentence from the private vocabulary
:zzdup
the VOC copy of zzdup

zzdup is in both, and the VOC's record is the one that ran. A private vocabulary can add a command. It can never replace one that the VOC holds. It can replace one that exists only in a catalog: with a program zzcatprog cataloged in the private catalog and a private record of the same name,

:zzcatprog
private vocabulary beats the catalog

ran the private record, not the program.

What else to know#

$voc.parser: handling a record type SD does not know#

001  X
002  type code {value mark type code ...}
003  handler {value mark handler ...}

Field 2 is a list of record type codes and field 3 a list of the names of cataloged subroutines, paired by position. Field 1 must be a capital X: a small x in this record is ignored.

When a command word has a record (in the VOC, in the private vocabulary, or made from a cataloged program, which SD treats as a V record), SD first runs down this list, and only then applies its own rules for V, PA, S, K and the rest. For each entry in order:

The first matching entry whose handler is cataloged wins.

A handler is a cataloged subroutine that takes two arguments:

subroutine zzhandler(verb, rec)
   crt 'handler verb=':verb:' type=':rec<1>:' f2=':rec<2>:' f3=':rec<3>:' sentence=':@sentence
return
end

It was compiled and cataloged (basic bp zzhandler, then catalog bp zzhandler). The VOC then held $voc.parser with field 1 X, field 2 ZZ and field 3 zzhandler, and a record zzcust whose field 1 is ZZ custom record type and whose fields 2 and 3 are alpha and beta. A new session gave:

:zzcust a b
handler verb=zzcust type=ZZ custom record type f2=alpha f3=beta sentence=zzcust a b

Without the $voc.parser record the same line was 'zzcust' is not valid for this usage. A handler with the wrong number of arguments ends the command with Argument count mismatch calling zzhandler (Call=2, subr=1) and the number of a line in the command processor (the session carries on).

When the list is read#

At sign-on, once. A record written during a session changes nothing in that session: zzcust was still not valid for this usage after the record had been written, and was handled in the next session.

Things this can do to a whole session#

Because it runs before SD's own rules, an entry can take over commands that already work:

A handler that only prints something leaves the commands it was given undone. Because run and off are commands too, the record cannot then be corrected from inside the account. The account's voc is a directory of files under the account's folder, so the way out is to remove that record from there with the operating system's own tools. Test a new entry on a copy of the account you can reach from outside before you put it on the one you use.

Who can make them#

Both records are changes to a VOC, so on Solo writing, changing or deleting either needs admin, like every direct change to the VOC (ed voc, a program's write or delete to it, copy into it, .s and .d with a name; see page 32a). Without it the change is refused with The VOC can only be changed after admin. Reading is never stopped. Solo has no voc-on, bp-on or shared account to give anyone a narrower right: there is admin or there is not.

What admin covers is the VOC, and only that:

See also#

SD VOC - Structure and Usage · SD VOC - Using and Managing the VOC · SD TCL - Programs and the Catalog.