home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / love / chap02.doc < prev    next >
Text File  |  1993-04-11  |  12KB  |  247 lines

  1.  
  2. Chapter2                L_O_V_E FORTH
  3.  
  4.  
  5.  
  6. 2.0  Compiling source code
  7.      ---------------------
  8.  
  9.  
  10.     L.O.V.E Forth allows considerable flexibility in the forms of 
  11. source code that it accepts. Programs can be loaded from screen format 
  12. floppy disks, or screen files and text files under MS-DOS.  These may be 
  13. intermixed as desired and nested within each other, up to ten levels deep.
  14.  
  15.          Many file words are named with a quote following (eg.
  16. INCLUDE", OPEN" ).  These words are followed by a file name, or a path
  17. and file name (eg.  INCLUDE"    MYFILE.TXT   or   OPEN"
  18. \WORK\SCREENS\PROG.SCR).  There should always be a closing quote (it
  19. may be omitted when it is the last item on a line that has been keyed
  20. in).  The word   "CLOSE, however, does not use a name. In this article,
  21. the words   BLOCK   and SCREEN are used interchangeably, both meaning a
  22. 1024 character fixed unit of disk storage.
  23.  
  24.          In order to load source code from screen format files or floppy
  25. disks, the block handling words must be loaded.  To load them, type:
  26. INCLUDE"     LOADBLK.TXT .    Once loaded, they may NOT be removed, as
  27. some kernel words are REDEFINED.
  28.  
  29.  
  30. 2.1  Loading MS-DOS text files
  31.      -------------------------
  32.  
  33.      Text files are convenient and efficient in use of disk space.
  34. Therefore L.O.V.E. Forth accepts source code from text files.  The word
  35. INCLUDE"     followed by MS-DOS path and file name, loads the specified
  36. file. There is a file size limit of 65535 bytes.
  37.  
  38.     Stand-alone editors are accommodated by the L.O.V.E. Forth DOS
  39. command.  Typing DOS, followed by the path and name of the desired text
  40. editor, begins an editing session.  To return to Forth, simply save the
  41. work, exit the editor, and load the desired file.
  42.  
  43.          There are several methods of commenting available in text
  44. files.  The usual Forth comment   ( )     works to a length of 256
  45. characters.  The line comment function     \     works for one line
  46. (until carriage return is encountered).  To comment out large portions
  47. of the text, the words   (( and ))     are available.  They may
  48. enclose any amount of space, and may be used around ( ) and \ .   They
  49. may not be nested within themselves.  To comment from one point to the
  50. end of the file, simply use (( without providing a closing )).   Note
  51. that )) is a Forth word and must be surrounded by spaces or
  52. end-of-line, return or enter.
  53.  
  54.          The word   EXIT   is often used to exit from the compilation of
  55. a Forth screen.  Because of this, it may not be used for this function
  56. in text files.   Simply use (( as is described above.   In addition,
  57. the words --> ,  LOAD"    and    THRU"    may not appear in text files
  58. as well.  LOAD"   and   THRU"   may be used instead to load screens
  59. from another file.
  60.  
  61.  
  62. Example:
  63.      LOAD" example.scr"   or   THRU" example.txt"
  64.  
  65.  
  66.      It is possible to load a screen file with   INCLUDE" .    In this
  67. case, however, it must not include any of the words described above or
  68. the Forth line comment     \     .
  69.  
  70.      If an error occurs while loading a text file, the previous
  71. twenty-four successfully loaded lines are displayed, and the erroneous
  72. word is highlighted.
  73.  
  74.  
  75. 2.2  Using screen files
  76.      ------------------
  77.  
  78.      L.O.V.E. Forth supports editing and loading of screen files.  A
  79. comprehensive screen editor and numerous utilities for screen handling
  80. are supplied.  The maximum file size accomodated is 32767 screens.
  81.  
  82.      The word   OPEN"   followed by a filename, opens an existing screens
  83. file for editing.  It becomes the 'current' file, which is accessed by
  84. block disk words such as   BLOCK    UPDATE   and   LINE
  85.  
  86.      To show contents of a screen on the display, there is a
  87. fast LISTing utility.  Type:   (screen-no) L   to list a screen.  The
  88. words LN, LB list one screen forward and backward respectively,   LL
  89. relists the current screen.   The word   EL   enters the full-screen screen
  90. editor at the current screen.
  91.  
  92.      The screen editor is a virtual vocabulary.  It may be entered at
  93. the current screen with   EL   or by:  (screen-no) EDIT   .
  94. Typing control-X   displays the help information.
  95. This editor provides facilities for general editing, 'gobbling' lines
  96. or words to a buffer, and moving from  screen to screen.
  97. To save the screen and exit from the editor, type:  ESCAPE and  F keys.
  98. Note that the 'gobble' buffers are lost if any compiling is performed,
  99. or if another virtual vocabulary is called in.  Do not use the editor
  100. on a write-protected disk, as it always writes the current screen, when
  101. moving between screens.
  102.  
  103.      To load from the current file, the words   LOAD"   and   THRU"   may
  104. be used. It is possible to load right from the editor by typing escape   L .
  105. Arrow  -->  may be included to proceed to the next screen and   EXIT   may
  106. be used to terminate loading at a point on a screen.  If any error
  107. occurs during loading, the erroneous screen becomes the current screen
  108. for listing and editing.  The word   WHERE   will display the screen with
  109. the erroneous word highlighted.
  110.  
  111.      The word   SHOW  performs the rapid listing of a range of screens.
  112. To slow it down, store a value into the variable   SHOWDELAY.   INDEX
  113. prints the first line only, from a range of screens.
  114.  
  115.      To create a new screens file, the word   OPEN-NEW"   followed by a
  116. path and file name is used.  It gives the file a starting size of two
  117. screens.  To obtain a larger file size, type:  (total screens) SCREENS .
  118. When in the editor, the file can also be extended, simply by advancing
  119. past the last screen in the file.  To open a different file, simply use
  120. OPEN"   or   OPEN-NEW".   The previous file is automatically closed.  To
  121. close the file explicitly, the word   "CLOSE   may be used (no word
  122. preceeds it).
  123.  
  124.      To copy a range of screens from one place on disk to another, the
  125. word   COPYSCRNS   may be used.  Pass in the starting screen, ending screen
  126. and destination screen.  Screens may be 'slid up' or down in the current
  127. file.  To erase a range of screens, the word   ERASESCRNS   is used (pass in
  128. start and end screens).  To put a header, with date time and screen
  129. number on a range of screens, use the word   SCRNHDS.
  130.  
  131.      To copy screens from file to file, the word   COPYF->F"   is used.
  132. Pass in the starting screen and ending screen in the source file, and
  133. the first destination screen in the destination file.  Follow this word
  134. with the source path\file and the destination path\file. For example:
  135.  
  136.         0 10 5  COPYF->F"\my-dir\file1.scr"myfile.scr"
  137.         There should be no space following the second " mark.
  138.  
  139.      To load a screen or range of screens from any screen file, the
  140. words   LOAD"   and   THRU"   may be used.   The values passed in are
  141. the same as  for LOAD and THRU, but the screens are loaded from the
  142. specified file.  The words -->   LOAD   THRU   may be used in the
  143. loaded file and operate within that file.  Additional files may be
  144. loaded from within those files with additional   INCLUDE"   LOAD"   or
  145. THRU"   commands.
  146.  
  147.      If an error occurs while loading a screens file, that file is
  148. left open for editing at the erroneous screen.  If an error occurs
  149. while loading a text file, no file is left open for editing.  If there
  150. are no errors, the file currently open before the loading remains so.
  151.  
  152.      Screen files may be converted to text files for more convenient
  153. programming.  The free-ware program    BUNBLOCK.EXE   is provided for
  154. this purpose.  Type   BUNBLOCK   with no arguments for help.
  155.  
  156.  
  157. 2.3  Using screens format diskettes
  158.      ------------------------------
  159.  
  160.      The traditional Forth source code storage is on floppy disks
  161. dedicated entirely to sequential screens. L.O.V.E. Forth supports both
  162. editing and loading of eight and ten sector formats.  Disks are accessed
  163. by bypassing MS-DOS.  Hard disks are not accessed.  There are also
  164. several utilities for conversion of screen floppies to screen files.
  165. The screen format facility must be explicitly enabled before use, as
  166. follows.
  167.  
  168.      When no screen file is open, Forth accesses the floppy disks in
  169. screen format.  All the block disk words and utilities described
  170. above may be used   LOAD   THRU  -->  SHOW   INDEX   WHERE   COPYSCRNS
  171. and  ERASESCRNS  .   In addition the words   LOAD"   THRU"   and
  172. INCLUDE" may appear on screens format diskette screens.
  173.  
  174.      There are two formats floppy screens available:  8 sectors
  175. per track and 10 sectors per track (320 or 400k per disk).  The former
  176. is the default setting.  To switch to and from 10 sectors, format the
  177. commands   10-SECTS-ON   and   10-SECTS-OFF   These are used
  178. (in   SCREEN-UTILS  vocabulary).  Floppy drives are treated as having
  179. contiguous screens.  Screen 319 (399) is the last screen on drive A:,
  180. and screen 320 (400) is the first on drive B:.   Note that accesses to
  181. floppies through MS-DOS functions confuse the screens format utilities
  182. (sets them to 9 sectors/track).  Two solutions to this: Refrain from
  183. using floppies for MS-DOS functions or switch to screen files.  Using
  184. virtual vocabularies from MS-DOS floppies will not cause problems.
  185.  
  186.      While a screens file is in use, and it is desired to list a
  187. single screen on a screens format floppy, use the command:
  188.     (scrn_no) LSCRN
  189. To copy from a screens format floppy to a screens file, the command
  190. COPYSCRNS->F"   followed by the path\file of an existing file is used.
  191. The starting screen, ending screen, and destination screen are passed
  192. in.   It is also possible to copy from a screens file to floppy screens
  193. with the command:   COPYF->SCRNS" followed by the source file, and with
  194. similar arguments passed in.
  195.  
  196.      INITDISK   will initialize a screens format floppy disk to the
  197. current sectors/track setting.  This word normally initializes drive B:.
  198. To initialize drive A:, execute the word   SETDRIVES,  which prompts the
  199. drive to use the word,   COPYDISK,   copies the entire disk from drive A:
  200. to B:, and the word   COMPDISK   compares the two (two drives are required
  201. for both words).  The word   COPYNEW   initializes drive B:, copies drive
  202. A: to B: and compares the two.
  203.  
  204.      The variable   BLKMAX   is used with screens format diskettes to set
  205. the maximum available screen.  If it is desirable to limit the action of
  206. editing, listing etc,  set this variable to the last usable block#.  The
  207. variable   OFFSET   is also used primarily with screens format diskettes.
  208. Its contents are simply added to the block number on block operations.
  209. For example, to make screen 0 refer to the first block on drive B,
  210. type:  0 ONB   OFFSET !
  211.  
  212.      Normally usage of screens floppy diskettes is disabled.  To
  213. enable the usage of these obsolete media, type:
  214.         SCREEN-UTILS ENABLE-SCRNS .
  215. To disable use:
  216.         SCREEN-UTILS DISABLE-SCRNS .
  217. These changes may be made permanent by doing a SAVE" of the Forth
  218. system.
  219.  
  220.  
  221. 2.4  Nested loading capability
  222.      -------------------------
  223.  
  224.      L.O.V.E. Forth allows files to be loaded from within other files.
  225. This permits screen files and text files to be intermixed and
  226. nested ten levels deep.  Simply include the appropriate loading
  227. word (eg.    LOAD"    or    INCLUDE"   )   in a screen or file.
  228.  
  229.                               Load the following:
  230.                          Screen disk:   Screen file   Text file:
  231. From:   Screen disk          *              *             *
  232.         Screen file                         *             *
  233.         Text file                           *             *
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.