                     Keeping it Simple
               Tips for beginning programmers
                   in the Basic Language.
                      by Joe Hochstuhl


        Physical Structure. In Basic, the structure or format of
the program does nothing for the program as far as operational
value is concerned. (Please do not confuse this with "Structured
Programming".) For this discussion we are simply referring to the
overall appearance of your code when viewed.

        I'm sure most people have viewed Basic code and noticed
the indentations in the appearance of the code. While this serves
no purpose to the compiler, it serves a vital purpose to the
person who has to debug the program at some point in the future.

        If it weren't for repair or upgrades, all Basic code
could be justified left, that is to say that all lines could
begin at column 1. And your program would run just as reliably as
it would otherwise. But it would become somewhat of a nightmare
when attempting to modify or perhaps find a programming bug.

        The following excerpt will run as reliably as the second
set:


*****************************************************************
' 1st example

beginblock:
CLS
DO
DO
choice$ = INKEY$
x = x + 1
IF x = 30000 THEN FLAG=1: EXIT DO
LOOP WHILE CHOICE$= ""
IF FLAG=1 THEN CLS: PRINT "Excessive inactivity... Terminating"
SELECT CASE(choice$)
CASE xxx
LOOP
RETURN
*****************************************************************

*****************************************************************
'2nd example

beginblock:
  CLS
  DO

    DO
      choice$ = INKEY$
      x = x + 1
      IF x = 30000 THEN FLAG=1: EXIT DO
    LOOP WHILE choice$ = ""

      IF FLAG=1 THEN CLS: PRINT "Excessive inactivity... Terminating"

        SELECT CASE(choice$)
          CASE xxx

  LOOP
RETURN
*******************************************************************

        In the above two examples, the 1st block does exactly the
same as the second block. So why worry about the indentations and
spaces? Simply put, if you had 4 pages of code, and it all looked
like block 1, I wish you luck when debugging and modifying. The
code tends to blend together, and it becomes very difficult to
tell where one routine starts and ends as opposed to all the
others.

        However, in the 2nd block, you can tell immediately upon
viewing the code, that you have a nested DO...LOOP. Additionally,
it is immediately obvious where one routine picks up and another
ends. Consequently, When you go to add to, or modify the existing
code, the task become much easier to do because of the structure
of the format.

        There is no steadfast rule in program format. It pretty
much goes as a preference from author to author. A reasonable
rule of thumb might go something like this:

        o A blank line between independent operations.
        o Two spaces indentation between primary, and decision
          loops. (can go deeper with multiple nested loops)
        o Keep block labels and their exit paths justified to the
          left.
        o Try and keep code on the screen, the less scrolling to
          the right it does, the easier to read and determine
          what is going on. Sometimes this cannot be helped, but
          keeping an eye on this will help later down the road.

NOTE: The code depicted above is for example only and the code
      contained within it only serves as an example of format
      structure.

                                                --JH
