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,zzhelloand the like are only examples. What differs on Solo from 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:
- 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-vdotfinds a VOC record calledzz.vdot. - 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-dotdoes not find a private record calledzz.dot. - The private catalog and then the global one, as page 32a describes.
- 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#
- The record is read every time. SD reads
$private.vocand opens the file for each command that the VOC does not hold, then closes it. Writing, changing or deleting the record takes effect on the next command, in the same session. - A record that does not work is ignored without a message. The command is
then reported as not in the VOC. That is what happens when field 1 is not
X(a record of typeFwas tried), when field 2 is empty, when the name is in no VOC record, and when the name leads to a place the account may not open (anFrecord namingC:/Windows, in an account without the OS access switch,set.os.access os on). - The file is opened as any file name is, under the same rules: a name
in the account's VOC (here
zzpv, whichcreate.fileput there). - A record found there is run as a VOC record is. A
Vrecord in modecathat names a cataloged program runs it. AVrecord in modeosis refused for an account without the shell switch (xx is not permitted to use the operating system shell), exactly as the same record in the VOC would be. AKrecord with no command in it is answered'zzkey' is not valid for this usage.
$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 record's field 1 and the type code are both put in upper case, and the
record matches if its field 1 begins with the type code. The match is a
prefix:
zzmatcheszz lower case type, andpwould match every record of typePA,PQorPH. - If the handler is cataloged, SD calls it as
call @handler(verb, record)and the command is finished.verbis the command word andrecordis the whole VOC record. The whole command line is in@sentence. - If the handler is not cataloged, SD says nothing and goes on to the next entry, and finally to its own rules.
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 type code of
vhands every verb to the handler, includingdateandoff, and SD's own code for it does not run.dateprinted only the handler's line. - A type code of
phands every paragraph; one ofk, every keyword record (displaywas handed over,datestill ran). - A blank type code matches every record. A list whose second value is
empty (
ZZ, a value mark, nothing) sendsterm,runandoffto the handler as well.
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:
- The private vocabulary's file is not covered. The test looks at the name of
the file being written, and a file called
zzpvis an ordinary data file. Once the VOC points at it, a session that can write the file can add commands to it and replace commands in it, withoutadmin. It still cannot touch the VOC's own records, so it cannot replace a VOC command. - A handler is a cataloged program. Cataloging to the private or local
catalog needs no
adminon Solo, soadminalone is what switches a handler on. - Neither record is in a stock VOC. Nothing SD ships writes them.
See also#
SD VOC - Structure and Usage · SD VOC - Using and Managing the VOC · SD TCL - Programs and the Catalog.