Forth Tutorial

Screen 1 not modified     
 0                  WELCOME TO FORTHTUT                            
 1                                                                 
 2    Brought to you by Larry Clayton with grateful acknowledge-   
 3    ment to Laxen and Perry, creators and donors of F83, of which
 4    forthtut is a small, introductory application.               
 5                                                                 
 6          Here you can taste the full flavor of Forth. If you    
 7     enjoy it and want to look into FORTH more deeply,           
 8     open up F83 on this ECCO disk.                              
 9                                                                 
10         If you want to spend money, you can buy a FORTH that    
11     is almost as good.                                          
12                                                                 
13        When you're ready to proceed, tell your computer         
14     "n L" and hit the return key.                               
15                                                                 


Screen 2 not modified     
 0                    Screen Control                               
 1                                                                 
 2     Say "1 LIST" to see the first screen.                       
 3     Say "L" to see the same screen again.                       
 4     Say "1 10 INDEX" for the first line of first 10 screens.    
 5                                                                 
 6     Say "N L" to see the next screen.                           
 7     Say "B L" to see the last screen.                           
 8     Remember this:  If you get in a panic and lose your way, say
 9     "1 list" and you'll start over at the beginning.            
10     Say 0 p-in and then "L" to get a a printout of this or any  
11     screen.                                                     
12     Say 0 p-in again to toggle the printer off.                 
13                                                                 
14                                                                 
15                                                                 


Screen 3 not modified     
 0 (              3rd Grade Arithmetic                             
 1  THE STACK IS (ALMOST) EVERYTHING.  YOU PUT A NUMBER ON         
 2 THE STACK WITH THE KEYBOARD, AND YOU TAKE IT OFF WITH A ".". IF 
 3 YOU SAY "2 . ", THE COMPUTER WILL ANSWER "2".  THE "2" WENT     
 4 ON THE STACK AND CAME FROM IT.                                  
 5 ".s" will show you what's on the stack without taking it off.   
 6    IF YOU SAY "2 2 + . ", THE COMPUTER WILL SAY "4". AND THE    
 7   STACK IS EMPTY.                                               
 8  IF YOU SAY "10 2 / . :, THE COMPUTER WILL SAY "5".             
 9  IF YOU SAY "10 2 * . ", THE COMPUTER WILL SAY "20".            
10   IF YOU WANT MORE MATH, YOU DON'T NEED A TUTOR, YOU NEED A     
11 TEXTBOOK.                                                       
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 4 not modified     
 0 (       Use a Space Between each Word!!!                        
 1      You make up your Forth in the same way you might have      
 2 BASIC if you had been the inventor.                             
 3     Here are some of the first words in my Forth, made up from  
 4 more basic words of the Forth inventor:                 )       
 5 : CLAYTON ." FORTH IS BEAUTIFUL   (L <CR> WILL GET YOU BACK)" ; 
 6 : 2NDWORD DARK cr cr cr cr cr 20 SPACES CLAYTON ;               
 7 : 3RDWORD 2NDWORD 4 TIMES ;    (  Now say "4 LOAD"              
 8    To see how Forth works say "3RDWORD <CR>" and watch          
 9 it flash.  Here are the primitive words which I used to make up 
10 my words: ":" ";" These two words form the beginning and the end
11 of every word which you can compile.  They tell the computer    
12 that you're making up a word.                                   
13 DARK tells the computer to clear the screen. ."         " tells 
14 the computer to display the enclosed string.  Don't forget the  
15 space after the word [."].  Now make up your own words!!!    )  


Screen 5 not modified     
 0 (          SAVING WORDS                                         
 1   IF YOU WANT TO KEEP YOUR NEW WORDS FOR TOMORROW, YOU SAVE THEM
 2 with Editor. Pick an empty screen, such as 17. Say "17 EDIT".   
 3 Now say "P" and type in what you want on 0 line.  It'll overwrit
 4 whatever might already be there.  Now say "n T", such as "1 T", 
 5 then "P" and put in your next item, perhaps something like      
 6 )                 : NEWWORD ." This is easy." ;                 
 7 (     Go ahead "T" and "P" your way down the page: lines 0 to 15
 8 You can go back and correct any typos with the same two commands
 9        If you want to start over, say "WIPE".  When you have it 
10 right, say "DONE".  The disk drive should light up; it's saved. 
11                                                                 
12 One last word: if you want the words on your screen to execute  
13 you have to say "17 LOAD" first; then you can call them and they
14 work.                                                           
15  To delete a word (and everything after) say FORGET <word>.     


Screen 6 not modified     
 0                    Screen to Screen                             
 1                                                                 
 2       Shuffling screens is a good trick--and simple.  Also dan- 
 3 gerous.  If you said "10 6 COPY", you would find this screen    
 4 replaced.  Don't do it unless you have a backup.                
 5      If you should want this screen at a different location,    
 6 such as at 15, say "6 15 COPY";you'll find it at both places.   
 7 By now you should know two ways to erase either one of them.    
 8                                                                 
 9       "File to File" is almost as simple.  Suppose you want to  
10 copy a screen from this file to MYFILE.BLK.  First you say      
11 "20 create-file myfile.blk".  Then you say "open myfile.blk".   
12  Then you say "from d.blk" and finally you say                  
13 "n1 n2" COPY".  Screen n1 of the FROM file shows up at Screen n2
14 of the other file.  Beautiful.                                  
15         Go ahead; you can do it.                                


Screen 7 not modified     
 0 (                   Disk to Disk                      cla       
 1      This is even simpler.  Put one of your files on a disk on  
 2 Drive B.  Now start FORTH like you always do on Drive A.  Now   
 3 say "OPEN YOURFILE.XXX".  Oops, it won't work.                  
 4 First you have to say "B:". Now say "OPEN YOURFILE.XXX"         
 5 and you should be in business.                                  
 6     How to get back?  Just say "A:".  That's the whole          
 7 ball game.  With this command and what you learned yesterday you
 8 can transfer a Screen from Disk A to Disk B. First open your re-
 9 ceiving file; then say "from" and name the drive and file.      
10    For example "from a:d.blk".  Then pronounce the magic words. 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 8 not modified     
 0                       Memory Map                      7NOV84CLAY
 1     This screen will help you get an idea of where things are.  
 2 BOOT of course is at the bottom of memory.  Next come the core  
 3 words.  Say " ' FORTH . "  That's where the dictionary starts.  
 4 Now say " ' EMPTY . " (or whatever your last word is).  That's  
 5 where the FENCE is.  You can't forget past that point.          
 6      You can locate the address in memory of any word, including
 7 your own words.  You can FORGET your words (See Lesson on Words)
 8                                                                 
 9      There are quite a few things above the dictionary.  Here we
10 only look at the screen buffers.  First say "#BUFFERS ."  That's
11 how many we have.  (When you become expert you can have more or 
12 less.)  Now say " FIRST ." That's where the buffers start.  Now 
13 say "LIMIT ." That's where they end.  The user area is just     
14 below the buffer area.         All this becomes more important  
15 as you GO FORTH.        You're learning.                        


Screen 9 not modified     
 0 (               To Stop the Action                              
 1                                                                 
 2    Suppose you have a screen of instructions for the user, and  
 3 you want to hold the screen until he's ready to proceed.  Here's
 4 a way to do it. (These words may be loaded from this screen)    
 5 : STARTER DARK ." Put the second part of your program here." ;  
 6 : KEYTOGO KEY ;                                                 
 7 : WAITER ." TO CONTINUE PRESS A KEY" KEYTOGO STARTER ;          
 8 ( Call your next sequence "STARTER".                            
 9 (Now write your screen and on line 15 put "WAITER". Be sure to  
10 load this screen and that one and you're home free.             
11                                                                 
12      If you want to wake him up put "BEEP" before "KEYTOGO".    
13                                                                 
14                                                                 
15                                                                 


Screen 10 not modified     
 0 (                REITERATION                          CLA       
 1    For a thrill say "10 LOAD" right now!!                       
 2          This screen has 3 things:                              
 3  1. Comments         --in parens like this one                  
 4  2. Word definitions ---between ": " and " ;"                   
 5  3. A word or program named OHWOW. It runs when you say 10 LOAD)
 6 : PREAMBLE DARK ." THIS COMPUTER IS SO SMART IT CAN COUNT TO 10.
 7  DO YOU WANT TO SEE IT?  PRESS Y.  " ;                          
 8 : GOAHEAD BEGIN KEY 89 = UNTIL ; ( 89 is ASCII for CAPITAL Y)   
 9 : FIRSTLINE CR ." HERE'S THE FIRST NUMBER " 2 SPACES 1 . ;      
10 : MYLOOP 11 2 DO CR ." HERE'S THE NEXT NUMBER " 2 SPACES        
11 I . LOOP ; ( MYLOOP executes everything between DO  and LOOP    
12 from time 2 through time 10.  I of course is the counter.)      
13 : TAIL 10 SPACES ." I'm sure you know enough to press L now." ; 
14 : OH-WOW PREAMBLE GOAHEAD FIRSTLINE MYLOOP TAIL ;               
15 OH-WOW     ( You can make up a loop of your own.    )           


Screen 11 not modified     
 0 (              Create your own file                   7NOV84CLAY
 1    You're ready now to develop your own Forth system.           
 2 Pick a name and put it with these magic words:                  
 3     "10 CREATE-FILE MYFILE.BLK"                                 
 4      You now have a file called MYFILE.BLK of 10 KB.            
 5   Your file has 10 empty screens to hold your words.            
 6       Using the Screen to Screen, File to File techniques       
 7  which you have already learned you can put any existing        
 8 screens that you want into your file. Or you can say "n EDIT"   
 9 and define any words or write any programs you want to.         
10       You're on your way to being an inventor like the rest     
11 of us.  Good luck.                                              
12 )                                                               
13                                                                 
14                                                                 
15                                                                 


Screen 12 not modified     
 0 (                 WORDS, WORDS, WORDS, WORDS                    
 1    For a real sensation say "WORDS".  You can stop it at any    
 2 point by pressing a key.  Every word is a program, most of them 
 3 made up of other more basic words.  You can see how they're made
 4 by saying "SEE WORD".  It won't mean much to you now, but       
 5 it will in a few days.  Any words you make up will be added to  
 6 the dictionary. They are put in the beginning.  If you get tired
 7 of them, say "FORGET MYWORD".  The machine will delete every    
 8 word up to and including MYWORD.                                
 9    There are several vocabularies. For example when you're in   
10 the Editor and say "WORDS", you get an entirely different list. 
11  If you say "VOCS", you'll get a list of the vocabularies.      
12 If you say "ORDER", you'll get the Context and Current vocabula-
13 ries.  If you want to know what that means, check your textbook.
14     If you spend a few days with these screens, you'll be       
15 ready to get the most out of F83.  You can do it!!  )           


Screen 13 not modified     
 0 (        F83 Versions 1 and 2 [ the CP/M programs.]             
 1      Version 1 appears on N.Jer.Sig Vol 154.                    
 2      Version 2 appears on N. Jer.Sig Vol 204.                   
 3 Version 1 has the commands "0 SET-DRIVE" and "1 SET-DRIVE".     
 4 Version 2 uses "A:" and "B:".                                   
 5 Version 1 may require words to be in caps.                      
 6 Version 2 doesn't care.                                         
 7                                                                 
 8     You should be able to get either one for about $6.  Or      
 9   download it free from a RCPM.                                 
10                                                                 
11    If all else fails, call me at 703 534 3137, and I'll help    
12   you get a copy.       DON'T CALL COLLECT!!                    
13                                                                 
14          YOU CAN GO FORTH.  )                                   
15                                                                 


Screen 14 not modified     
 0                                                                 
 1                                                                 
 2                                                                 
 3                                                                 
 4                                                                 
 5                                                                 
 6                                                                 
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 15 not modified     
 0  ( the good old printer)                                        
 1   Here's something worth knowing:                               
 2     Say "0 p-in l".                                             
 3   Better yet say "0 0 p-in l p-in l."                           
 4    It toggles.                                                  
 5   To print the whole thing say "0 p-in 0 list" and then         
 6  "n l 15 times" . )                                             
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 16 not modified     
 0  ( Boot)                                                        
 1  open d.blk                                                     
 2         : howdie dark 20 spaces ." FORTHTUT -- written by Larry 
 3 Clayton" cr                                                     
 4  10 spaces ." in the public domain Forth system of Laxen and Per
 5 ry" cr cr 20 spaces ." for ECCO and the PUBLIC DOMAIN"          
 6                                               cr cr cr 10 spaces
 7  ." May be freely copied but not sold for profit."  cr cr cr cr 
 8 ." Neither the author nor distributor has any responsibility for
 9 "  ."  financial loss    resulting from the use or abuse of this
10  program." cr cr cr cr 20 spaces ." Hit a key when ready."      
11    EMPTY-BUFFERS   ONLY FORTH ALSO DEFINITIONS   DEFAULT        
12     key dark d.blk 1 list    ;                                  
13 ' howdie IS BOOT                                                
14                                                                 
15                                                                 


Screen 17 not modified     
 0                                                                 
 1  : newword ." this is easy." ;                                  
 2                                                                 
 3                                                                 
 4                                                                 
 5                                                                 
 6                                                                 
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15