V5N3 - Complang
V5N3 - Complang
V5N3 - Complang
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The defining word DIRECTORY at<br />
compile time takes two values from the<br />
stack which at run time will be used as<br />
arguments for ESTABLISH.<br />
: DIRECTORY 2CONSTANT DOES ><br />
2@ ESTABLISH ;<br />
You could define a word DOC which,<br />
when executed, would establish the<br />
current working directory for<br />
documentation as follows (assuming it<br />
to be on 45 through 47):<br />
45 47 DIRECTORY DOC<br />
You can even get the values from the<br />
current working directory<br />
NAME DOCDlR<br />
NAME DOC-DIR-END<br />
DIRECTORY DOC<br />
assuming that the current working<br />
directory has entries<br />
DOC-DIR 45 DOCDIR-END 47<br />
DOC will change the current working<br />
directory to the documentation direc-<br />
tory. Any number of working direc-<br />
tories can be thus defined.<br />
Every system will have a standard or<br />
default working directory. To get back<br />
to it we say MAIN. On this disk it is<br />
defined<br />
78 82 DIRECTORY MAIN<br />
The actual work of NAME is done by<br />
SUBJECT. NAME picks up the limits for<br />
the current working directory and<br />
executes SUBJECT. SUBJECT takes the<br />
next word in the input stream and puts<br />
it in PAD. It then does CONNIVE, which<br />
will look for that word on the screens<br />
indicated. Only the names are<br />
compared - the values are skipped<br />
over to make the search faster.<br />
INTRIGUE is used by CONNIVE to look up<br />
the word in PAD on a single screen.<br />
When and if the word in PAD is found,<br />
the next word will be interpreted.<br />
SUBJECT can be used to define words<br />
similar to NAME and VIEW for special<br />
directories. A "help" system could be<br />
defined something like:<br />
: HELP ( --- )<br />
HELP% 2@ SUBJECT LIST ;<br />
With shadow screens it could be even<br />
easier.<br />
: HELP ( --- )<br />
NAME >SHADW LIST ;<br />
,<br />
SCR# 71<br />
( you may already have some of these. )<br />
-1 CONSTANT TRUE 0 CONSTANT FALSE<br />
: DEFINED ( --.:name:';. a,f 1 < -' rift --or- )<br />
-FIND ( this is .figforth "-FIND )<br />
IF 64 ( pr-ecedence blt 1 AND<br />
IF 1 ( it's immediate 1 ELSE -2 THEN<br />
SWAP CFA SWAF<br />
ELSE HEKE 0 THEN ;<br />
: HAVE ( --.IN !<br />
REPEAT FALSE -<br />
: INTERPRET-&-WORD ( --. )<br />
( interprets a word 1<br />
DEFINED<br />
IF EXECUTE<br />
ELSE NUMRER ( dDl 3 CN if drop then )<br />
THEN ;<br />
CONTINUED ( n -- ) ( b/scr Ir ) RLK ! 0 >IN ! ;<br />
73 LOAD 74 LOAD ( directory system)<br />
78 82 DIRECTORY MAIN MAIN<br />
SCK# 73<br />
( @a+ directory system wwb/wwb 830714)<br />
: INTgIGUE ( -- fla ) ( search the screen )<br />
REGIN MORE ( aidr,f)<br />
IF PAD DUP C3 1+ COMPARE ( 0 for e ual )<br />
IF E(L WORD 01 ( 0) ELSE TRUE EXIT THEN<br />
THEN<br />
UNTIL-. .FALSE ;<br />
: CONNIVE ( scri,scr2 -- ) ( (name>. is in "PAD")<br />
ELK 3 >.IN 3 >.R >.R TFUE ROT ROT 1+ SWAP<br />
DO I ( b/scr Ir ) BLK C/L ( skip top line ) >IN i !<br />
INTRIGIJE IF NOT LE~VE THEN<br />
LOOP ABORT" not. in directory It<br />
INTERPRET-?-WORD,<br />
R>. R> >.IN . ELK . ;<br />
: SUEJEIX ( scri.scr2 --*:name>) ( find and execute<br />
EL WORD COUNT'PAD 2DUP C! 1+ SWAP CMOVE CONNIVE ;<br />
8CRY - .- . . . 74 .<br />
( eas directory system wwbl 'wwb 830724)<br />
~VFIRI~RLE DIRX<br />
I %DJR ( .-- scr 2 scr2 ) DIRZ<br />
I ESrABLISH ( scri,scr2 -- 2: 5<br />
) DIRX 2. j<br />
: DIRECTORY ( scri,scr2 --<br />
ZZCONSTANT DOES) ( -- 1 k9 FSTABLISH :<br />
: NAME ( --IN 3 HAVE - It- DROP ELSE > .IN ! NAME LOAD THEN J<br />
: FOLLOW ( --. )<br />
>IN 3 IiAVE IF. DROP ELSE :,.IN ! WAM$ CONTINUED THEN ;<br />
: RUN ( --*:name.:. 1 >IN 3 NEED .>.IN , ;<br />
: DIR ( ---(:name;? ) XDIH MIN LIST<br />
: SUE( ( scr ---%:name:;. n -or ci D U SUBJECT ~ i<br />
PROCEDAMlJS WWB '7/ 14/83<br />
End Listing<br />
FORTH Dimensions 12 Volume V, No. 3<br />
)