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 examples on this page are for an ordinary account, not the administrator's. The names
zzpv,zzhelloand the like are only examples.
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 the switch 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 naming/etc, in an account that does not holdos-on; the administrator's own session does open it). - 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), and failing that a file of the shared account (see below). - 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:
zzcustwas stillnot valid for this usageafter the record had been written, and was handled in the next session. logtodoes not read the new account's record. A session that signed on to an account with a$voc.parserrecord kept that list afterlogtoto an account without one, and was handled by it there. A session that signed on to an account without the record did not use the record of the account it went to.
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, the administrator's session included.
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. It was removed from outside, by the
administrator signed on to the sdsys account running an ordinary program
that opened the account's voc by its path and deleted $voc.parser; after
that the account worked again. Test a new entry on an account you can reach
from outside before you put it on one you cannot.
Who can make them#
Both records are changes to a VOC, so writing, changing or deleting either
needs the voc.edit switch, which SDSYS gives with modify.account
name voc-on, or SDSYS itself. Without it a program's write is refused
with status 3035, and a program with no on error stops with The VOC can
only be changed by an account that has voc.edit. Reading is never stopped.
What the switch covers is the VOC, and only that:
- The private vocabulary's file is not covered. The switch looks at the
name of the file being written, and a file called
zzpvis an ordinary data file. Once the VOC points at it, any session that can write the file, in an account with no edit switch at all, can add commands to it and replace commands in it. This was run: an account with all three switches off wrote a new record and replacedzzhello, and both ran. It still cannot touch the VOC's own records, so it cannot replace a VOC command. - A file in the shared account.
$private.vocmay name a file of the shared account, found by name by an account that holdsshared.read(on unless SDSYS turns it off). Such an account ranzzshcmdfrom it; an account withshared.readoff did not find the file. The first account's write to that file was refused with status 3035, becauseshared.writeis off unless SDSYS turns it on. So a private vocabulary kept there can be changed only by SDSYS and by accounts SDSYS has givenshared.write. The shared account's own VOC is not searched for commands; only this pointer reaches its files. - A handler is a cataloged program, and cataloging needs
bp.edit(Programs can only be compiled or cataloged by an account that has bp.edit).voc.editalone is enough to switch on a handler that is already cataloged: an account withvoc-onand nobp-onwrote the record and the handler ran. - 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.