Benutzer-Werkzeuge

Webseiten-Werkzeuge


papierkorb:sample1.blk

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

papierkorb:sample1.blk [2025-08-16 17:50] – ↷ Seite von projects:sample1.blk nach papierkorb:sample1.blk verschoben mkapapierkorb:sample1.blk [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1
Zeile 1: Zeile 1:
-=== Examples and notes for lecture # 1 === 
  
-<code> 
-print Screen 0 not modified      
- 0 \ Examples and notes for lecture # 1           13:10JWB04/09/87  
- 1 \ Last change:   Screen  009                   13:38JWB04/09/87  
-                                                                  
-         Making new words.                                        
-         How to get in/out of the system                          
-         Simple programs.                                         
-         Numeric input.                                           
-         The outer interpreter.                                   
-         How to use the editor VEDIT.                             
-         How to use the HELP system.                              
-10         Some important system words.                             
-11                                                                  
-12 The B.C. Chapter of the FORTH Interest Group meets at BCIT       
-13 in Room 1A-324 on the first Thursday of each month.              
-14 The FORTH Board is a Computer Bulletin Board System run by BCFIG 
-15 Phone: 434-5886 if you have a modem and communication software.  
- 
- 
-Screen 1 not modified      
- 0 \  Load screen for HELP system                 12:54JWB04/09/87  
-                                                                  
- 2 ONLY FORTH DEFINITIONS                                           
-                                                                  
- 4 \ These words require  DEVICE=ANSI.SYS to be in you CONFIG.SYS   
- 5 \ file and the the ANSI.SYS driver to be on your boot disk.      
-                                                                  
- 7 : ESC[   27 EMIT ASCII [ EMIT ;                                  
- 8 : CLS    ESC[ ." 2J" ;                                           
- 9 : BRIGHT ESC[ ." 1m" ;                                           
-10 : NORMAL ESC[ ." 0m" ;                                           
-11 : BLUE   ESC[ ." 44m" ;                                          
-12                                                                  
-13 FROM HELP.BLK   1 LOAD  ( loads the HELP system )                
-14                                                                  
-15                                                                  
- 
- 
-Screen 2 not modified      
- 0 \ Entering and Exiting the FORTH System.       13:14JWB01/09/86  
- 1 FORTH83 {name}.BLK    Enter F83 sytem with the enhanced editor   
-                       called VEDIT.  The screen file {name}.BLK  
-                       is opened.                                 
- 4 FORTH83 B:SAMPLE1.BLK Enter FORTH with this file attached.       
-                                                                  
- 6 BYE                   Exit the FORTH system and return to DOS    
-                                                                  
- 8 F83     {name}.BLK    Enter F83 sytem with using Laxen and Perry 
-                       screen editor. The screen file {name}.BLK  
-10                       is opened.                                 
-11 F83     SAMPLE1.BLK   Enter FORTH with this file attached.       
-12                                                                  
-13 Note:  I have never used the Laxen and Perry editor, so you are  
-14        on your own here.   See the file README.PC for help if    
-15        you would like to try this out.                           
- 
- 
-Screen 3 not modified      
- 0 \  Elementary Word Definitions.                13:22JWB01/09/86  
-                                                                  
- 2 : {name}    word1  word2 . . . wordn  ;                          
-                                                                  
- 4 :       Begin a word definition.                                 
- 5 ;       End a word definition.                                   
- 6 {name}  This is the name of the new word definition.             
-                                                                  
- 8 Example:                                                         
-                                                                  
-10 : FIRST   CR  ." This is my first FORTH program. "  ;            
-11                                                                  
-12 ."  {string}"   Compiles string,  when word is executed string   
-13                 is displayed on the display or console device.   
-14 CR              Start a new line. ( carriage return/linefeed )   
-15                                                                  
- 
- 
-Screen 4 not modified      
- 0 \ Working with FORTHs word dictionary.         13:07JWB04/09/87  
-                                                                  
- 2 \ WORDS         List all words in the FORTH dictionary.          
- 3 \ EMPTY         Remove all new words added since entering FORTH  
- 4 \ FORGET {name} Remove {name} and all words defined since {name} 
- 5 \               from the FORTH dictionary.                       
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 5 not modified      
- 0 \                                              13:07JWB04/09/87  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 6 not modified      
- 0 \ PHONE LIST                                   10:14jwb09/15/85  
-                                                                  
- 2 : JACK      ."  BROWN       596-9764"                            
-             ."   or   434-5734 L5401" CR ;                       
- 4 : GEORGE    ."  SMITH    999-1111   " CR ;  EXIT                 
- 5 \ EXIT above prevents the rest of this screen from compiling.    
- 6 :           ."                      " CR ;                       
- 7 :           ."                      " CR ;                       
- 8 :           ."                      " CR ;                       
- 9 :           ."                      " CR ;                       
-10 :           ."                      " CR ;                       
-11 :           ."                      " CR ;                       
-12 :           ."                      " CR ;                       
-13 :           ."                      " CR ;                       
-14                                                                  
-15                                                                  
- 
- 
-Screen 7 not modified      
- 0 \ CHECKER BOARD                                10:14jwb09/15/85  
-                                                                  
- 2 : BLACK   SPACE SPACE ;                                          
-                                                                  
- 4 : WHITE   177 EMIT 177 EMIT ;                                    
-                                                                  
- 6 : ROW1   CR BLACK WHITE BLACK WHITE BLACK WHITE BLACK WHITE ;    
-                                                                  
- 8 : ROW2   CR WHITE BLACK WHITE BLACK WHITE BLACK WHITE BLACK ;    
-                                                                  
-10 : BOARD  CR ROW1  ROW2  ROW1  ROW2  ROW1  ROW2  ROW1  ROW2  ;    
-11                                                                  
-12 : CHECKER_BOARD    BOARD  CR CR ;                                
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 8 not modified      
- 0 \ ANOTHER CHECKER BOARD                        10:14jwb09/15/85  
-                                                                  
-                                                                  
- 3 : BLACK   SPACE SPACE ;                                          
-                                                                  
- 5 : WHITE   177 EMIT 177 EMIT ;                                    
-                                                                  
- 7 : ROW1   CR 4 0 DO  BLACK WHITE LOOP ;                           
-                                                                  
- 9 : ROW2   CR 4 0 DO  WHITE BLACK LOOP ;                           
-10                                                                  
-11 : BOARD  CR 4 0 DO  ROW1  ROW2  LOOP ;                           
-12                                                                  
-13 : CHECKER_BOARD    BOARD  CR CR ;                                
-14                                                                  
-15                                                                  
- 
- 
-Screen 9 not modified      
- 0 \ MQUIT                                        13:38JWB04/09/87  
- 1 \ This stack print is more compact and uses unsigned for HEX #s. 
- 2 : .S ( --  -- )                                                  
-      DEPTH ?DUP IF                                               
-            0 ?DO DEPTH I - 1-  PICK                              
-                  BASE @ 16 = IF U. ELSE . THEN  LOOP             
-                 ELSE ." Empty" THEN ;                            
- 7 \ My quit routine which displays stack after each operation.     
- 8 : MQUIT  ( --  -- )                                              
-         SP0 @  'TIB ! BLK OFF [COMPILE] [                        
-10         BEGIN   RP0 @   RP!                                      
-11                 STATE @ NOT                                      
-12                 IF CR .S ASCII > EMIT SPACE THEN                 
-13                 QUERY  RUN                                       
-14         AGAIN ;                                                  
-15                                                                  
- 
- 
-Screen 10 not modified      
- 0 \       VEDIT CURSOR CONTROL                   10:50jwb09/15/85  
- 1 up      arrow or control E      move cursor one position up      
- 2 down    arrow or control X      move cursor one position down    
- 3 left    arrow or control S      move cursor one position left    
- 4 right   arrow or control D      move cursor one position right   
- 5 tab     key   or control I      move cursor one tab stop right   
- 6 shift tab     or control O      move cursor one tab stop left    
- 7 control A or                                                     
- 8 control left arrow              move cursor one word left        
- 9 control F                                                        
-10 control right arrow             move cursor one word right       
-11 return  key     move to end of text on next line.                
-12 home    key     move to start of text (upper left screen corner) 
-13 end     key     move to end of text (last character on screen).  
-14 control home    move to the beginning of the current line.       
-15 control end     move to the last character of the current line.  
- 
- 
-Screen 11 not modified      
- 0 \       VEDIT - DELETE, ERASE & INSERT         11:20jwb09/15/85  
- 1 Del  key or                                                      
- 2 control G       delete character under cursor and close gap.     
- 3 back space      erase  character behind cursor leaving a blank.  
- 4 control T       delete remainder of word and close gap.          
- 5 control U       erase  current line leaving a line of blanks.    
- 6 control Y       delete current line and close gap.               
- 7 alt           erase  from cursor position to end of line.      
- 8 F9              erase  entire screen to blanks.                  
- 9 alt     F9      erase  from cursor position to end of screen.    
-10 Ins  key        toggle between overstrike and insert mode.       
-11 control N       insert a blank line at the current position.     
-12 alt           split  line at current cursor position.          
-13 control J       join   current line with one below.              
-14 control W       insert a blank at current cursor position.       
-15                                                                  
- 
- 
-Screen 12 not modified      
- 0 \       VEDIT - SEARCH REPLACE, LINE STACK     12:26jwb09/15/85  
-                                                                  
- 2 control Q       then press any character.  Find first occurance  
-                 of character following cursor position.          
-                                                                  
- 5 F7              find first occurance of string.                  
- 6 control L       repeat find for the current string.              
- 7 F8              find and replace string (one replace).           
- 8 F8              (answer prompts with return)  repeat with        
-                 previous strings.                                
-10                                                                  
-11 F3              push current line to line stack without deleting 
-12 F5              pop  top of line stack to current line.          
-13 F4              push current line to line stack and delete it.   
-14 F7              insert top of line stack at current line.        
-15                                                                  
- 
- 
-Screen 13 not modified      
- 0 \       VEDIT - SCREEN CONTROL                 12:17jwb09/15/85  
- 1 PgUp    or control R    move back one screen.                    
- 2 PgDn    or control C    move to next  screen.                    
- 3 control PgUp            move to first screen in file.            
- 4 control PgDn            move to last  screen in file.            
-                                                                  
- 6 F9                      erase current screen to blanks.          
- 7 F10                     restore current screen disk copy.        
- 8 control Z               prompt for new screen # and zip there.   
- 9 alt                   alternate between screen and its shadow. 
-10 control P               quick print of current screen.           
-11 alt                   copy one screen to another.              
-12 alt                   copy many screens to a new location.     
-13 alt                   quick screen index.                      
-14                                                                  
-15                                                                  
- 
- 
-Screen 14 not modified      
- 0 \       VEDIT - SPECIAL                        13:33JWB01/09/86  
- 1 control J       join current line with one below.                
- 2 control P       quick print of current screen.                   
- 3 F1              display help screen.                             
- 4 alt           choose better colors for screen display.         
- 5 alt           copy one screen to another.                      
- 6 alt           transpose character right.                       
- 7 alt           get directory of disk drive.                     
- 8 alt           quick screen index.                              
- 9 alt           copy many screens to a new location.             
-10 alt           open new screen file.                            
-11 alt           transpose character left.                        
-12 alt           change tab stops.                                
-13 F10             restore current screen form copy on disk.        
-14 ESC             exit the editor.                                 
-15                                                                  
- 
- 
-Screen 15 not modified      
- 0 \                                              12:24jwb09/15/85  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 16 not modified      
- 0 \ Looping words, I/O words, Stack operatio     13:40JWB01/09/86  
-   last first   DO  ...  LOOP    ( Use within a colon def to )    
-                                 ( loop from first to last.  )    
-   last first  ?DO  ...  LOOP    ( Same as above except loop )    
-                                 ( 0 times if   first=last      
-     BEGIN  ....  AGAIN          ( Use within a colon def to )    
-                                 ( create an infinite loop.  )    
-     SPACE       ( --   -- )     ( Send a space to the display.)  
-     SPACES      ( n    -- )     ( Send n spaces to display. )    
-     CR          ( --   -- )     ( Start a new line on display.)  
-10     EMIT        ( n    -- )     ( Display ASCII character n .)   
-11               ( n    -- )     ( Send top of stack to display.) 
-12             ( m n   sum )     ( Leave sum:  sum = m + n      ) 
-13             ( m n   dif )     ( Leave difference: dif = m - n) 
-14             ( m n   prod )    ( Leave product: prod = m * n  ) 
-15     .S          ( --   -- )     ( Non destructive stack print. ) 
- 
- 
-Screen 17 not modified      
- 0 \ Stack, Directory, Screen access              13:45JWB01/09/86  
-     MAX         ( m n   max )   ( Leave larger  of m and n )     
-     MIN         ( m n   min )   ( Leave smaller of m and n )     
-     DEPTH       ( --    n     ( Leave count of stack items.)   
-                               ( Comment to end of line       
-      this is a comment  )                                      
-     A:          ( --   -- )     ( Make the current drive A )     
-     B:          ( --   -- )     ( Make the current drive B )     
-     DIR         ( --   -- )     ( List current drive directory.) 
-     LIST        ( n    -- )     ( List screen or block n .)      
-10     LOAD        ( n    -- )     ( Compile screen n .)            
-11     INDEX       ( m n  -- )     ( Index screens m through n .)   
-12               ( --   -- )     ( List the current screen. )     
-13     N L         ( --   -- )     ( List the next  screen. )       
-14     B L         ( --   -- )     ( List the previous screen.)     
-15                                                                  
- 
- 
-Screen 18 not modified      
- 0 \ Operations with screen files.                13:46JWB01/09/86  
-     FILE?       ( --   -- )     ( Display current screen file.)  
-     DEFAULT     ( --   -- )     ( Revert to default screen file) 
-                                 ( used when FORTH was started.)  
-     OPEN  <name>.BLK            ( Open an existing screen file.) 
- 5 \  Create a new screen file  <name>.BLK  with n blank screens.)  
-     CREATE-FILE <name>.BLK  ( n   -- )                           
-     MORE        ( n    -- )    ( Add n blank screens to the    ) 
-                                ( end of the current screen file) 
-     QUERY       ( --   -- )    ( Fetch a line of text from user) 
-10     INTERPRET   ( --   -- )    ( Interpret the text line word by 
-11                                ( word.)                          
-12     VEDIT       ( n    -- )    ( Begin editing screen n )        
-13     VED         ( --   -- )    ( Begin editing current screen )  
-14     CAPACITY    ( --    )    ( Leave number of screens in the  
-15                                ( current screen file.)           
- 
- 
-Screen 19 not modified      
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 20 not modified      
- 0 \ Check book register.                         10:41JWB03/25/86  
- 1 \ Print balance forward.                                         
- 2 : BFWD  ( bal    bal )    5 SPACES DUP    .  CR ;                
- 3 \ Display amount of next entry and the new subtotal.             
- 4 : +.  ( s1 n   s2)                                               
-       DUP       + DUP    .  CR ;                               
- 6 \ Done with this months checks, print the new total.             
- 7 : DONE ( s    -- )                                               
-        CR  ." ====================================="             
-        CR  ."  You have . . . . "  .  ."  dollars left." CR ;    
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 21 not modified      
- 0 \ My checking account                          10:41JWB03/25/86  
- 1 CR                                                               
- 2 .( Balance forward )    1000   BFWD                              
- 3 .( Pay Check          1200   +.                                
- 4 .( Mortgage        )    -500   +.                                
- 5 .( Hydro              -120   +.                                
- 6 .( Food            )    -200   +.                                
- 7 .( Telephone           -25   +.                                
- 8 .( Entertainment       -15   +.                                
- 9 .( Car Payment        -300   +.    DONE EXIT                   
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 22 not modified      
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 23 not modified      
- 0 \ Hard copy screen documentation.              19:58JWB09/26/85  
-                                                                  
- 2 \ Print three screens starting with n on the printer.            
- 3 : HTRIAD  ( n   -- )                                             
-         PRINTING ON DUP 3 +  SWAP   27 EMIT 69 EMIT              
-         DO CR I LIST LOOP  PRINTING OFF ;                        
-                                                                  
- 7 \ Send a top of page command to printer.                         
- 8 : FFEED                                                          
-         PRINTING ON 12 EMIT PRINTING OFF ;                       
-10                                                                  
-11 \ Print screens  first through last  on printer, three per page. 
-12 : DOC   ( first last   -- )                                      
-13         1+ SWAP DO I HTRIAD FFEED 3 +LOOP ;                      
-14                                                                  
-15                                                                  
- 
-</code> 
papierkorb/sample1.blk.1755359401.txt.gz · Zuletzt geändert: 2025-08-16 17:50 von mka