home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / tech / design2 / pbas.doc < prev    next >
Text File  |  1986-08-30  |  11KB  |  226 lines

  1.                   PBAS, or "PROCESS a BASIC PROGRAM"
  2.  
  3.  
  4. PBAS.BAS, put together by: Tom Story
  5.                            Lawrence Livermore Lab
  6.                            Livermore, CA  94550
  7.                            
  8.  
  9. This program is a concatenation of two very useful public domain programs:
  10. SQUISH.BAS and XREFBUZZ.BAS whose documentation appears below in the 
  11. original with appended comments. Numerous bugs were repaired and also 
  12. many cosmetic changes were made to both programs.
  13.  
  14. As far as I can tell, the SQUISH portion functions as advertised. The XREFBUZZ
  15. or cross-reference portion does not leave out any references. However it does
  16. add erroneous references. Specifically, it prints Hex and Octal numbers as line
  17. numbers; and it prints "D" and "E" exponents as variables. Also the bytes
  18. information at the end of the table occasionally prints negative numbers (I
  19. think for larger programs only?). A look at the program listing will also
  20. reveal the possibility for future BASIC version reserved words to be listed
  21. as variables unless they are added to the "DATA" block.
  22.  
  23. Again, as far as I can tell no references are ommitted so the above bugs
  24. are merely a nuisance and I'm sure myself or someone will resolve them
  25. eventually. 
  26.  
  27. In using PBAS, ignore the operating instructions in the original documentation
  28. below and follow the menus in PBAS. Also, as I have modified the programs
  29. I have renamed them SQUASH.BAS and XREFBAS.BAS so as to distinguish them
  30. from the unmodified source codes.
  31.  
  32.  
  33.  
  34. SQUASH portion:
  35.  
  36. "Squish" is a utility program for the IBM PC with 32K,
  37. color/graphics adapter, 1 disk drive, and Basic.
  38.  
  39. (The following is condensed from SoftSide magazine, issue no. 34.):
  40.  
  41.      Programmers tend to use quite a few REMarks when
  42. programming, add extra spaces to make listings more readable, as
  43. well as putting only a few statements on each line.  The result
  44. is a program that is easier to read and debug, but not very space
  45. or memory efficient.  The ideal utility would remove extra spaces
  46. and REMs, and combine lines, when possible without altering the
  47. structure of the BASIC program.
  48.      Enter the TRS-80 program Squish...if only it were translated
  49. to the IBM PC.  We've done so, and it is presented here for the
  50. benefit of all our IBM subscribers.
  51.  
  52.  
  53. TO USE SQUISH:
  54.      First LOAD the program you wish to pack.  After it is
  55. loaded, SAVE it with the ASCII option to a new file.  For example:
  56. LOAD "MYPROG.BAS" and then reSAVE it as "MYPROG.ASC",A.  After
  57. the program has been saved with the ASCII option, LOAD in
  58. "Squish" and type RUN.
  59.      Answer the first question with the name of the file saved
  60. with the ASCII option ("MYPROG.ASC" in the example above).
  61.      You will then be given a series of options.  You can remove
  62. extra spaces, delete REMarks, and combine lines.  The fourth
  63. option gives you the ability to protect a line or group of lines
  64. from being "Squished."  Lines entered under this option are
  65. totally ignored by "Squish."
  66.      "Squish" will then read in the program to check for lines
  67. that are referenced and proceed to work on it.  The display will
  68. update constantly to show, in color (or monochrome), what
  69. "Squish" is doing, and where.
  70.      When "Squish" is done, it will allow you to enter the
  71. "Squished" program for examination.  I suggest you then do a
  72. quick RENUMber and reSAVE the program under another filename.
  73.      When you are finished, you will have a neatly renumbered
  74. program that is not only much shorter than the original (usually
  75. by a few K), but will execute faster.  All in all, "Squish" is
  76. quite a useful utility.
  77.  
  78.  
  79. VARIABLES;
  80.      A: Temporary numeric storage.
  81.      A$: Current program line being Squished.
  82.      AZ: Screen line on which current program line is displayed.
  83.      C$: Contains lines that have been combined.
  84.      D: Length of a reserved word being searched for.
  85.      DS: The maximum number of user protected lines.
  86.      DT: Set to 1 if current line contains a DATA statement.
  87.      G1 - G6: A position in A$ at which INSTR starts searching.
  88.      HH: Miscellaneous.
  89.      I$: Name of a DEF FN to convert a string input into a single upper
  90.                case letter.
  91.      IP$: Set to "Y" if REM statements are to be deleted.
  92.      J$: Storage for A$ as it is being reconstructed.
  93.      LN: Current line number being processed.
  94.      L$, L1$: Current character of A$ being processed.
  95.      N$: Set to STR$(LN).
  96.      P: Set to 1 the first time a quote is encountered in a PRINT
  97.                statement.  Set to 0 when second quote or end of
  98.                line is encountered.  While P equals 1, all
  99.                compression functions are cancelled.
  100.      PJ: Points to the current line in PRO(*) being tested.
  101.      PP: Set to 1 minus the location of the first character in a
  102.                program line following the line number.
  103.      PV: Number of protected lines entered.
  104.      PRO(*): Optional protected line numbers specified by user.
  105.      Q$: Used in an INKEY$ loop.
  106.      R: Number of line numbers referenced in REF(*).
  107.      RD: Total number of REM statements deleted.
  108.      RE: Total number of lines combined.
  109.      REF(*): Number of program lines that can be referenced.
  110.      S,S1: Miscellaneous.  Used in sort routine.
  111.      SD: Total number of spaces deleted.
  112.      SQ$: SAVE filename for Squished program.
  113.      SV$: SAVE filename for Squished program.
  114.      T,T1-T2: Miscellaneous.
  115.      V$: The current program line stripped of its line number.
  116.      X: Set equal to PP.
  117.      XC$: Set to "Y" if lines are to be combined.
  118.      XS$: Set to "Y" if extra spaces are to be deleted.
  119.      XP$: Set to "Y" if user wishes to protect lines.
  120.      ZC: Position on line AZ to print L$.
  121.  
  122.  
  123. 2/9/83 Patches, enhancements, etc. by Herb Shear
  124.  
  125. The R pointer can no longer lag behind allowing referenced REM and '
  126.   statements to be deleted.
  127. Trailing ' no longer added on nonnull referenced lines.
  128. RESTORE & RETURN references to a line now protect the line.
  129. Constructs like X=IGOTO+35 no longer protects line 35.
  130. Indentation was preserved even when combining.
  131. The deblanking tests were extended to close up constructs such as
  132.   A( I ),  etc.
  133. Goofs in naming the input file are now handled in a friendly fashion
  134.   instead of repeating the entire input session over again.
  135.  
  136.  
  137. 3/02/86 Bugs found, by Tom Story.
  138.  
  139. Program as distributed does not work, found bugs in the following lines:
  140. 170 thru 190, 210, 220, 290, 400, 500, and 560. Lines 185 and 560 had multiple
  141. bugs. The function for returning line numbers in line 290 was changed as VAL
  142. returns the wrong number when a "D" or "E" follows the line number.
  143. Dimensioning was modified slightly to accomodate the IBM Basic Compiler.
  144. A function was added to strip out line numbers for the Basic Compiler /N option.
  145. These bugs were corrected, several cosmetic changes were made, the program
  146. renumbered, and renamed SQUISH2.BAS. Probably more bugs lurking.
  147.  
  148.  
  149.       Users should take note of the instructions to use SAVE"-----",A
  150. files as input.  Squish is tuned to the interpreter's output which is a
  151. subset of valid input forms.  Lowercase, blanks preceding line numbers
  152. and `GO TO xxx' are not handled properly by Squish.
  153.  
  154.  
  155.  
  156. XREFBAS portion:
  157.  
  158.         This program reads a BASIC program, saved in ASCII
  159. format by using the ",A" option of BASIC, and prepares either a
  160. neat listing, a cross-reference list, or both.  The
  161. cross-reference list shows, for each symbol and each referenced
  162. line number, the line numbers in which they occur.  This is a
  163. highly valuable aid to debugging.  It assists the user in
  164. finding inadvertent uses of the same variable name for two
  165. different purposes, or of different variable names where the
  166. same one was intended, and in locating the source of improper
  167. branches.
  168.  
  169.         The program was contributed to the BPC by Jeff
  170. Friedhoffer, and has been revised by Jim Fennessey.  It was
  171. originally published in the June 1981 issue of Interface Age
  172. magazine, and was adapted to the IBM PC by Steve Nossen.  This
  173. program may not be sold and may not be used for commercial
  174. gain.
  175.  
  176.         The program asks for filespecs of BASIC programs to be
  177. processed.  Up to 9 separate programs may be processed in a
  178. single run of XREF1.  The programs to be processed should have
  179. been previously saved using the ",A" option to produce an ASCII
  180. file, and should be resident in one of the disk drives.  The
  181. output specification defaults as the printer, but may also be
  182. the communication port or a disk drive.  It is generally most
  183. convenient to ask for the output to be sent to a disk, using
  184. the same name as the original program, and the extension
  185. ".XRF".  Then, once the XREF1 program has finished, you may use
  186. the DOS COPY command to copy filname.XRF to the printer.
  187.  
  188.         XREF1 provides an ongoing indication of its progress
  189. through the program files, and sounds a distinctive tone when
  190. it finishes.  Thus, it may be left running unattended if
  191. desired.
  192.  
  193.         One feature worth noting is that if XREF1 encounters a
  194. line in the input program which ends in the characters  'PG
  195. then it will begin a new page of the output listing with that
  196. line of the input program.  Thus, if your input program has
  197. several major sections, you can arrange it so that XREF1 starts
  198. each new major section on a new page.
  199.  
  200. This Cross reference pgm came from the Baltimore PC Users Group
  201. Diskette offering.
  202. PROGRAM NAME: XREF.EXE
  203. AUTHOR:V1.1 Steve Nossen, V1.2 Buzz Hamilton Boston User's Group
  204. ABSTRACT: This is a compiled and corrected version of one of the BASIC
  205. cross reference listing generators found on one of our earlier disks.
  206. Users of any of those earlier programs should abandon them, and use this
  207. one. Buzz Hamilton has heavily modified and corrected the best of the
  208. original three, and then the program was compiled for a drastic increase
  209. in it's operating speed.  Cross reference listings are useful
  210. when you are debugging or documenting programs - the locations of all
  211. references to variable names or line numbers are listed in an easy to read
  212. format.
  213. REQUIRES: IBM PC with BASIC language.  A printer is extremely helpful but
  214. not strickly necessary.
  215. INSTRUCTIONS: First, this program must reside on a disk which contains
  216. your system COMMAND.COM. Second, the program for which you desire a cross
  217. reference listing must have been saved on disk in ASCII form (,A option).
  218. Then from DOS, type XREFBUZZ<cr> and answer the questions about file names etc.
  219.  
  220. 6/27/86 Bugs found, by Tom Story.
  221.  
  222.  1). Added BASIC 3.0 reserved words.
  223.  2). Added references by RESTORE and RETURN.
  224.  3). Corrected CSNC to CSNG as reserved word.
  225.  4). Fixed problem with reserved word embedded in a variable name.
  226.