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