home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / doc / chapter3.txt < prev    next >
Text File  |  1989-10-29  |  16KB  |  340 lines

  1. CHAPTER 3.  HYPERTEXT BROWSER
  2.  
  3.  
  4.  
  5.  
  6. On-line documentation was originally used by Forth, Inc. to allow its
  7. users a fast access to the source and documentation of all the compiled
  8. code.  The command LOCATE and its abbreviation LL (VIEW in F83) looks up
  9. a word in the dictionary and find the block from which the word is
  10. compiled and displays the text in this block.  The command "A" alternates
  11. between the source block and its corresponding shadow block, which
  12. contains comments and documentation on the compiled word.  This technique
  13. was also used in F83 to provide access to multiple files of source and
  14. help texts.
  15.  
  16. F-PC 2.25 inherited the VIEW mechanism from F83 to display the source
  17. code.  Instead of combining the source code and shadow documentation in a
  18. single file, F-PC put the documentation in separated .HLP files.  Hence a
  19. new word HELP was defined to access the help files.
  20.  
  21. George Hawkins developed a browsing utility which allows a user to browse
  22. words freely in the editor.  The user moves the editing cursor over a
  23. word, with a single key stroke the proper source file is opened and the
  24. source code of this word is displayed in the editor window.  With this
  25. capability in the editor, the user can lookup any word in F-PC quickly
  26. which greatly helps the programming process.
  27.  
  28. Tom Zimmer was duely impressed with the browser.  He extended the
  29. browsing mechanism to include not only the source code but also arbitrary
  30. documentation.  He ended up with a powerful hypertext-like on-line
  31. documentation system, which is the main attraction of F-PC 3.5.  Tom also
  32. spent much efforts in building a substantial amount of tutorial and
  33. documentational materials on the hypertext system to help a new user to
  34. get acquainted with F-PC.
  35.  
  36.  
  37. 3.1.    LAUNCH THE HYPERTEXT BROWSER
  38.  
  39.  
  40. The best way to learn F-PC is to use it.  If you have F-PC installed
  41. according to the procedure outlined in  Chapter 2, change your current
  42. directory to C:FPC and type "F" to execute the F.EXE your saved.  A
  43. sign-on screen appears on the screen and F-PC comes to life.
  44.  
  45. On the top of your screen is a status line.  The two leftmost fields show
  46. you the number of free bytes in the Code space, and that in the List
  47. space.  The third item tells you how many items are on the data stack.
  48. Normally the data stack is empty, and it shows the "Stack Empty" message.
  49. The fourth item is the drive/directory/filename field.  It shows your
  50. current directory.  If a file is opened, the file name appears after the
  51. directory path.  The rightmost field show the current time, which is
  52. obtained from the DOS clock.
  53.  
  54. Under the current time is a picture of the vocabulary stack.  The topmost
  55. item is the current vocabulary to which new definitions are linked.  The
  56. next is the context vocabulary stack, which shows the vocabulary search
  57. order.  Most often the current and the top context vocabulary are FORTH,
  58. and the ROOT vocabulary is at the bottom of the vocabulary stack.
  59.  
  60. The status line shows you the most vital information about F-PC.  It is
  61. updated whenever you hit a key on the keyboard.  Keep an eye on it
  62. occasionally as you work.
  63.  
  64. The text in the sign-on screen suggests that you use F1 and ESC keys to
  65. get more information about F-PC.  Pushing F1 launches the browser and
  66. displays the root screen of the hypertext help system.  A file
  67. FPCHELP.TXT is opened, the SED text editor is invoked, and you are put in
  68. the browsing mode to examine the features of F-PC.
  69.  
  70. Pushing ESC key causes a menu bar to appear under the status line.
  71. Pushing <return> or <down- arrow> pulls down a menu.  Use the up and down
  72. keys to select a menu item, followed by <return> to execute the
  73. selection.  You can create a new file for editing, or open an old file,
  74. spawn a DOS shell, quit F-PC, or launch the hypertext browser.
  75.  
  76. Use either method to launch the browser and start experimenting F-PC.
  77. You are in the browsing mode of the SED editor, looking at the beginning
  78. of the FPCHELP.TXT file.  The text is enclosed in a double-line border,
  79. which indicates that you are in the browsing mode.  If you are in the
  80. editing mode, the border is drawn using single-lines.
  81.  
  82. A status line is at the top of the display.  This line contains various
  83. pieces of information about the file being browsed or edited, including
  84. the word BROWSE at the left hand side. When you are in the editor, the
  85. word BROWSE will change to INSERT, or OVERWRITE indicating the
  86. appropriate edit mode.
  87.  
  88. The bottom line displays the name of the file being viewed, and a couple
  89. of helpful hints. HELP=F1, and MENU=ESC. F1 will link you into another
  90. copy of the hypertext help system where you can get help on the various
  91. editor functions.
  92.  
  93. You can press F1 now if you want to, and press F10 to come back here.
  94.  
  95. Pressing the ESC key will cause a menu bar to be displayed. Having
  96. pressed ESC, you can press the first letter of a menu name, or use the
  97. keypad arrow keys to move around on the menubar. Pressing Enter while a
  98. menu item is selected will cause the specified operation to be performed.
  99. Pressing ESC again while the menubar is visible, will make it go away.
  100.  
  101. Use Down Arrow or the PgDn key on the keypad to advance through the
  102. FPCHELP.TXT file, and the Up Arrow or PgUp key to backup toward the
  103. beginning of a file. Press F10 when you want to unlink to the previous
  104. browser.
  105.  
  106.  
  107. 3.2.    NAVIGATE F-PC WITH THE BROWSER
  108.  
  109.  
  110. To browse F-PC is very easy.  You move the cursor around using the arrow
  111. keys and the PgUp/PgDn keys.  After you position the cursor on a word
  112. that you are interested, push <return> or F9 key, and the browser will
  113. try to find more information about that word.  If the word is a Forth
  114. command, the browser will open the corresponding source file and display
  115. the source code of this command.  If the word is displayed in reversed
  116. video, indicating that it contains a link, pressing <return> or F9 will
  117. lead you to the text linked to this word.  You can also use the TAB key
  118. to jump from the current cursor location to the next hypertext link.  The
  119. shift-TAB key moves the cursor to the link immediately above the cursor.
  120.  
  121. <Return> and F9 keys allow you to search deeper and deeper into the
  122. hypertext system.  F10 allows you to back out to the last link you
  123. pointed to.  Keep on pressing F10 will eventually lead you back to the
  124. root help screen.
  125.  
  126. F-PC hypertext help system present you with 8 major topics:
  127.  
  128.         Hypertext               How to use the hypertext system
  129.         Hyper-System            How to build your own hypertext system.
  130.         Get-Started             Introduction to F-PC.
  131.         SED-Help                Editor help and documentation.
  132.         Forth-Help              Help on Forth words in F-PC.
  133.         F-PC-Utils              Documentation on F-PC utilities.
  134.         Preferences             Select options in F-PC.
  135.         Whats-new               Update and bug-fixes.
  136.  
  137. Each of these topics starts a tree of tutorial or documentation.  It is a
  138. very interesting system to explore interactively.  Since F-PC is such a
  139. huge system and no one can possible remember all the words and the
  140. command key sequences, this hypertext system makes all these pertinent
  141. information available at your fingertip.
  142.  
  143.  
  144. 3.3.   A SAMPLE SESSION 
  145.  
  146.  
  147. Once F-PC has been installed on your computer, you can start it up by
  148. typing "F-PC <return>" or "F" from the keyboard.  This will display a
  149. sign-on message about the version number, available memory, etc.  Type
  150. HELLO will display this sign-on screen any time.
  151.  
  152. To open a file, type the following:   
  153.  
  154.         OPEN   BANNER <return>
  155.  
  156. The file BANNER.SEQ will be opened.  We can load it with: 
  157.  
  158.         1   LOAD <return>
  159.  
  160. This prints a nice demo message.  This demo came from the F83X system
  161. written by Wil Baden.
  162.  
  163. We can edit the source for BANNER by typing: 
  164.  
  165.         ED <return>
  166.  
  167. You will now be in the editor, viewing the first 23 lines of BANNER.SEQ.
  168. You can page down through the file with the PgDn key on the keypad, and
  169. back up with the PgUp key.  For now, page down to the bottom of the file
  170. with PgDn, and there you see the definition of the word DEMO, which
  171. prints out our demonstration banner.
  172.  
  173. Now let's create a new file and put a new DEMO definition with your own
  174. banner message in it. Leave the editor by typing Alt-F10 ESC.  You will
  175. now be back in Forth without saving any changes you may have accidentally
  176. made to BANNER.SEQ.
  177.  
  178. To create the new file, type the following: 
  179.  
  180.         NEWFILE   MYBANNER <return>
  181.  
  182. F-PC will start the editor, and try to open the file MYBANNER.  If it is
  183. present, F-PC will open it. If it is not, then F-PC will automatically
  184. create a new file called MYBANNER.SEQ and place you in the editor in that
  185. file, prepared to accept text.
  186.  
  187. Type in the following definition, using the <return> key to add new lines
  188. to the file as needed. The arrow keys can be used to move around, but you
  189. will not be allowed to move below the mass of the reversed colored blank
  190. characters, as they represent the end of the current file.
  191.  
  192.         :   MYBANNER      ( --- )
  193.                         " HELLO"   BANNER
  194.                         " FROM"   BANNER
  195.                         " YOURNAME"   BANNER   ;
  196.  
  197. Note that YOURNAME must be no longer than 11 characters. 
  198.  
  199. Now that you have typed in or edited the above definition into the file
  200. MYBANNER.SEQ, leave the editor while saving the text you have entered, by
  201. pressing F10 ESC.
  202.  
  203. Let's compile the program.  Type: 
  204.  
  205.         FLOAD   MYBANNER <return>
  206.  
  207. The file MYBANNER.SEQ is opened, and loaded.  If you entered the program
  208. as shown, then all should be well, and Forth should come back with the
  209. "ok" message.  You could have also compiled the program by typing 1 LOAD
  210. <return>, since the file was already open.
  211.  
  212. Now that MYBANNER is compiled, type its name to make it do its stuff: 
  213.  
  214.         MYBANNER <return>
  215.  
  216. You should have seen your name scroll up on the screen.  If you didn't,
  217. try editing the source file and correcting your typing error.
  218.  
  219. At this point, you can VIEW the source for MYBANNER by typing: 
  220.   VIEW MYBANNER <return>
  221.  
  222. F-PC will locate the source for your MYBANNER word, and display the
  223. source code starting at the line where MYBANNER was started.  A shorter
  224. word for VIEW called V is provided to save typing.
  225.  
  226. After all these work, you are ready to quit.  Type:
  227.  
  228.         BYE <return>
  229.  
  230. and you will return to DOS, which displays the familiar C> prompt.
  231.  
  232.  
  233. 3.4.    A SHORT TUTORIAL
  234.  
  235.  
  236. The browser is a great tool to explore F-PC.  You can jump from place to
  237. place, looking at documentation and code at will.  However, to program in
  238. F-PC, you need a set of basic tool words which allows you to compile
  239. words in files, examine the dictionary, and test the code.  As the editor
  240. will be covered in detail later, we will give you a short tutorial on
  241. these tool words.  You are assumed to know Forth from other Forth
  242. textbooks and manuals, and we will not try to teach you Forth.  However,
  243. Dr. Jack Brown runs an on-line tutorial on the North Coast Forth BBS,
  244. (604) 434-5886.  The tutorial materials are also available from GEnie,
  245. (800) 638-9636.  Dr. Brown had agreed to upgrade the tutorial based on
  246. F-PC 2.25 to 3.5 and will shortly make it available in print.
  247.  
  248. Following is a list of words that you have to know very well to be able to use F-PC effectively:
  249.  
  250.  To open an existing file:                      OPEN <filename>
  251.  To edit a file already open:                   ED
  252.  To leave the browser:                          F10      or ESC F E
  253.  To leave the editor and save changes:          F10      or ESC F E
  254.  To leave the editor and discard changes:       Alt-F10  or ESC F Q
  255.  To create and edit a new file:                 NEWFILE <newfilename>
  256.  To load a file:                                FLOAD <filename>
  257.  To load a file already open:                   OK  or  1 LOAD
  258.  To view/browse a words source:                 VIEW <word>
  259.                                                 BROWSE <word>
  260.         Some short cuts to view and browse:     V  <word>  or   B <word>
  261.  To edit source of a word:                      ED <word>  or   E <word>
  262.  To see all words containing a string:          WORDS <substring>
  263.         WORDS can be followed by two substrings:WORDS <substring> <substring>
  264.  To de-compile a dictionary word to the screen: SEE <word>
  265.  To find all occurrences of a string in a file: FLOOK <string> <filspec>
  266.  
  267.  
  268. Some specific examples are given in the following.
  269.  
  270.         WORDS H <return>                \ Display all words in dictionary containing "H".
  271.  
  272.  --[ FORTH ]--                          \ F-PC displays these words
  273.          OPEN            $HOPEN         HOPEN
  274.  
  275.         VIEW  HOPEN <return>            \ Enter the browser displaying the source code for
  276.                                         \ HOPEN.  Press F10 to leave the browser.
  277.  
  278.         ED <return>
  279.  
  280. After performing the above command sequence, ED will enter the editor on
  281. the source for HOPEN. This is like the browser but you have to be careful
  282. not to make any changes.  Press Alt- F10 to leave the editor and not
  283. saving changes.
  284.  
  285.                 FLOAD SWINDOW <return>
  286.  
  287. If the file SWINDOW is present on your disk, it will be compiled.  You
  288. can now type "POPUP" to see a sample popup window. You may get an error
  289. message if the file SWINDOW.SEQ is not present on your disk.
  290.   OPEN SWINDOW.SEQ ED <return>
  291.  
  292. This command will open the file SWINDOW, and enter the editor. The
  293. extension .SEQ is used automatically if no extension is specified.
  294.   OK <return>
  295.  
  296. Will compile the currently open file. This is the same as FLOAD but works
  297. on the most recently edited or viewed file.
  298.   SEE HEX <return>
  299.  
  300.  F-PC displays: 
  301.  
  302.         : HEX           16 BASE ! ;
  303.  
  304. Allows you to see the source for a colon definition without having the
  305. source file available on disk.
  306.  
  307. Here are some additional words you can use to manipulate files.
  308.  
  309.         <n1>  LOAD                      \ Start loading file at <n1>.
  310.             LISTING                     \ Print out the current file.
  311.             NEWFILE <newfile>           \ Create the file <newfile> if it
  312.                                         \ does not already exist, and edit it.
  313.             INDEX                       \ Display first line of all .SEQ
  314.                                         \ files in current directory.
  315.  
  316. The above examples should be enough to get you at least started in
  317. exploring F-PC.  If you are the type of person who likes to read
  318. everything before experimenting, then continue on and you will find out
  319. how to print the documentation included with F-PC.
  320.  
  321. There is a considerable amount of documentation provided on disk to
  322. assist you in discovering F- PC.  Actually it is provided on disk because
  323. many of you won't have this F-PC Users Manual available to help you get
  324. started. We of course recommend you get the F-PC Users Manual, it was
  325. generated on a Macintosh, and laser printed. It is a good reference, with
  326. a good glossary, and is available from Offete Enterprises for $20.00
  327. dollars plus postage.
  328.  
  329. If you insist on making printouts of all of documentation files, here is
  330. a command to print a text file in the current directory:
  331.  
  332.         FPRINT <filename.TXT> <return>
  333.  
  334. Be sure your printer is ready for printing. If you are going to print all
  335. the documentation, have at least several hundred sheets of paper
  336. available to complete the job.  The F-PCGLOS.TXT file is too large to
  337. print from F-PC, use the demo Z editor provided.  Z is on the fourth F-PC
  338. distribution diskette.
  339.  
  340.