home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / basic / pbs.lbr / -PBS.DZC / -PBS.DOC
Text File  |  1988-05-06  |  6KB  |  185 lines

  1.                                P B S
  2.                                -----
  3.  
  4.                      A pre-processor for BASIC.
  5.                      --------------------------
  6.  
  7.                          by Lee David Rimar
  8.  
  9.  
  10.               Inspired by PREBAS, a program by G. Wolfe
  11.                 PBS stands for PreBas, Small version
  12.  
  13.  
  14. PBS is intended as an aid to BASIC programmers.  With it they can 
  15. enter a program in their favorite text editor or word processor, 
  16. while not worrying about line numbers, or the targets for their GOTO 
  17. and GOSUB statements.  PBS then takes the un-numbered ASCII file, 
  18. adds line numbers to it, and resolves references to target labels.
  19.  
  20. PBS was written in Microsoft BASIC (MBASIC) and was compiled with 
  21. BASCOM.  You should have these files in this library:
  22.  
  23.  
  24.   -PBS.DOC       This file
  25.  
  26.   PBS-O.COM      Stand-alone compiled program, linked with
  27.                  OBSLIB.REL
  28.   
  29.   PBS-S.COM      Small version of compiled program, requires
  30.                  BRUN.COM to run.
  31.  
  32.   PBS.PBS        Source code ready for PBS processing
  33.                  (yes, PBS can preprocess itself!)
  34.  
  35.   PBS.BAS        Source code ready for compiler/linker
  36.  
  37.   CTAIL.REL      Relocatable module needed for compiling.
  38.                  Gets command line from CP/M
  39.  
  40.   UCASE.REL      Relocatable module needed for compiling.
  41.                  Converts strings to upper case
  42.  
  43.  
  44. Because PBS is coded with CALLs to those to RELocatable modules, it 
  45. won't run under the MBASIC interpreter without some modifications.
  46. Remarks in the source code annotate what needs to be changed.
  47.  
  48.  
  49.                              RUNNING PBS
  50.                              -----------
  51.  
  52.  
  53. First, decide which version of PBS you want to use.  PBS-O.COM will 
  54. run on any CP/M system, and doesn't need any other files.  PBS-S.COM 
  55. is much smaller, but you must have BRUN.COM present on the currently 
  56. logged disk.  Whichever one you decide to use, rename it PBS.COM.
  57.  
  58.  
  59. Then from the CP/M command line, just enter:
  60.  
  61.   A>PBS TEST.BAS
  62.  
  63. This will take an ASCII (non-document) file called TEST.PBS and make 
  64. a new file called TEST.BAS.  Don't enter the file extents; they 
  65. default to .PBS for the input file and .BAS for the output file.
  66.  
  67. This new file (TEST.BAS) will have line numbers at the start of each 
  68. line, starting with 1 and incrementing by 1 each time.   If you want 
  69. different line numbers, you can load the resulting file in MBASIC and 
  70. issue a RENUM command.
  71.  
  72. An "'" will be inserted into any line starting with a label 
  73. (identified by an "@" as its first character).  Any references to 
  74. that label will be translated into references to the actual line 
  75. number.  Appended to the end of any line containing references to 
  76. target labels will be a comment like " ' @LABEL " for each label 
  77. translated to a line number.
  78.  
  79. PBS also strips out leading and trailing "white space" on a line.  
  80. When working with your .PBS program file with your text editor, you 
  81. can indent lines to make loop structures more evident.  But the extra 
  82. spaces will be stripped from the .BAS output file; this lets programs 
  83. run a bit faster.
  84.  
  85. For example, Say we had a file called TEST that looked like this:
  86.  
  87. '------------------------------------------------------------
  88. '       @TEST -- A test for PBS
  89. '
  90. '------------------------------------------------------------
  91. @START -- This is the start of the program.
  92. FOR J = 1 TO 20
  93.     GOSUB @ROUTINE
  94. NEXT J
  95. '
  96. INPUT "DO YOU WANT TO EXIT"; A$
  97. IF A$ = "Y" THEN GOTO @END ELSE GOTO @START
  98. '
  99. @END
  100. '
  101. END
  102. '
  103. '
  104. @ROUTINE
  105. PRINT "INSIDE ROUTINE"
  106. RETURN
  107.  
  108. The command:
  109. A>PBS B:TEST 
  110. would produce a file called TEST.BAS that looked like this:
  111.  
  112. 10 '------------------------------------------------------------
  113. 20 '      @TEST -- A test for PBS
  114. 30 '
  115. 40 '------------------------------------------------------------
  116. 50 '@START -- This is the start of the program.
  117. 60 FOR J = 1 TO 20
  118. 70 GOSUB 180 ' @ROUTINE
  119. 80 NEXT J
  120. 90 '
  121. 100 INPUT "DO YOU WANT TO EXIT"; A$
  122. 110 IF A$ = "Y" THEN GOTO 130 ELSE GOTO 50 ' @END ' @START
  123. 120 '
  124. 130 '@END
  125. 140 '
  126. 150 END
  127. 160 '
  128. 170 '
  129. 180 '@ROUTINE
  130. 190 PRINT "INSIDE ROUTINE"
  131. 200 RETURN
  132.  
  133.  
  134.                                LABELS:
  135.                                -------
  136.  
  137. PBS recognizes labels if, (A): their first character is a @ 
  138. character, and (B): they are whole words.
  139.  
  140. PBS recognize as a target line any line where the first word, 
  141. (whether preceded by white space, or not), is a label (has the 
  142. marker character as its first char.). If there are duplicate 
  143. labels, the first one will be used as the target.
  144.  
  145. Compare the PBS.PBS and PBS.BAS files included in this library for a 
  146. better idea of how labels are used.
  147.  
  148.  
  149.                          MISCELLANEOUS NOTES
  150.                          -------------------
  151.  
  152. In 1985, G. Wolfe ("Greywolf") wrote a program called PREBAS.BAS, 
  153. which was distributes as "freeware."  I liked that program, but found 
  154. it somewhat clumsy to use.  It was also quite large, and ran slow.
  155.  
  156. I didn't use PREBAS very much, until recently when I started doing 
  157. quite a bit of BASIC programming again (who says BASIC is a dead 
  158. language?).  But the problems bothered me so much that I decided I 
  159. would try to modify it.  
  160.  
  161. After a few false starts, I ended up writing my own program from 
  162. scratch.  So while this program was inspired by the original PREBAS, 
  163. they have not a single line of code in common.
  164.  
  165. PBS lacks many options which PREBAS offered.  PREBAS had two 
  166. modes of operation:  from CP/M command line, or with prompts.  It 
  167. also had a variety of options:  It could add or STRIP line 
  168. numbers from a file; the user had more flexibility on input and 
  169. output file names; and could also set the starting line number 
  170. and increment size.  But I never used those options.  So I wrote 
  171. PBS to simply emulate PREBAS's defaults in the command line mode.
  172.  
  173. For my uses, PBS is a better program.  It's simple, small, and fast.
  174. But as it's not as flexible as PREBAS; some people might prefer to 
  175. have that program instead.  It's available on many RCP/Ms.
  176.  
  177. "Try it; you'll like . . . "
  178.  
  179.  
  180.  
  181. Lee David Rimar                                       1 May, 1988
  182.  
  183.  
  184.                               -eof-
  185.