home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / quicksub / quicksub.doc < prev    next >
Encoding:
Text File  |  1986-06-12  |  4.1 KB  |  76 lines

  1. QUICKSUB.DOC                        12 June 86
  2.  
  3.         QUICKSUB.LBR contains some of my better subroutines 
  4.     written in MSDOS QuickBASIC. I hope they are useful to those
  5.     who program in QuickBASIC, and I hope others will study the
  6.     code.  It's not PASCAL, but it's not BASIC, either. I like
  7.     working with it very much.  The code is far easier to write
  8.     and to understand than is BASIC. Take a look at my time
  9.     simulation program -- SIMTIME.ASC.  I think it is beautiful.
  10.     MNULIN is pretty, too.
  11.  
  12.         I would really appreciate looking at how others code
  13.     in QuickBASIC. The rules are rather open; much of my form comes
  14.     from my own preferences for layout. Then there is the naming of
  15.     variables and lines -- that, too, is my invention, borrowing
  16.     heavily from my assembly language preferences. My preference is
  17.     to comment in mixed case, and to program in CAPS. But QuickBASIC
  18.     allows you to write code in lower case, the preference of many
  19.     PASCAL and C programmers. Notice how heavily you can comment
  20.     the code and how flexible you can be in where you place the 
  21.     comments. 
  22.  
  23.         I have my own convention for setting the file extensions;
  24.     I use BAS to designate a program that will run in BASICA, ASC to
  25.     designate a program that will run only in QuickBASIC, and SUB to
  26.     designate a QuickBASIC subroutine that must be $INCLUDE'ed in the
  27.     calling program. In general, ASCII-saved BAS files will also work
  28.     in QuickBASIC, but many BASIC programs need modification. About the
  29.     only thing QuickBASIC will not do is BLOAD, but CALL seems to work
  30.     fine in place of it.
  31.  
  32.         Here's how I convert BASICA programs -- First, I strip out
  33.     unneeded line numbers from an ASCII-saved conventional program. For
  34.     this I use REMLINE, which came with QuickBASIC. After filtering
  35.     through REMLINE, I immediately try to compile it with BASCOM. This
  36.     usually pukes out a bunch of errors that I write down. REMLINE
  37.     sometimes removes line numbers that are needed -- BASCOM catches this
  38.     fact.  At this time, it is easy to go into the file and replace the
  39.     stripped line numbers. Then I make the changes noted from the compiler
  40.     error messages. It gets a bit hazy here, but I'm working to the point
  41.     where the program will compile without any error messages. Once I get
  42.     here, I do something that will make it all much easier. I wrote a
  43.     program I call WOW, that will take my program and strip out the
  44.     executable statements, one per line. Then I begin the process of 
  45.     formatting and commenting the code.  I have taken very complicated
  46.     programs written by others with no comments and made sense of them
  47.     with this technique.  You'll be surprised how much more understandable
  48.     the code is when it is spread out and formatted. Then I begin to 
  49.     replace line numbers with sensible names, mebbe changing variable
  50.     names in the same way. I forgot -- before I do ANY of this, I run
  51.     a complete cross-reference on the program.  I use my customized 
  52.     (and QuickBASIC'ed) version of PC-XREF, a super program. With this
  53.     cross-reference data, I begin to have a sense of the variables and
  54.     busy line numbers.  Back to the middle . . I start separating out
  55.     all the subroutines, getting them tight and pretty, finally putting
  56.     them in the best spot.  Then I begin to search the code for chances
  57.     to make more subroutines, eliminating redundant code. While I'm 
  58.     doing this, I'm looking to speed up and simplify the code, moving and
  59.     changing it, eliminating variable names that could be combined in 
  60.     another general purpose variable. This takes experience, and I've
  61.     made a lot of mistakes to have earned the experience.  It's fun,
  62.     though, like working a crossword puzzle. By this time, I am familiar
  63.     enough with the code that I am enhancing it -- searching to improve
  64.     its feel, function, look, performance. And always, learning from 
  65.     what someone else has done.
  66.  
  67.         There are things I've yet to explore:
  68.             Calling assembly language subroutines
  69.             Using MAKE to handle compilation
  70.             Possibly setting up LIBS of subroutines for MAKE
  71.             The unknowns that YOU will tell me about
  72.  
  73.     ENJOY . . .
  74.  
  75.         David L. Poskie   Madison, WI
  76.