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


PART 1

     This is the first of a series of programming tips for
people wishing to get started in Basic. Tips you will find in
this column will be straight forward.


     As you beginning learning Basic, one thing all programmers,
including the experts, must adhere to is a bit of foresight.
Consider for the moment, who all might use your program in the
future. And how easily will the end user be able to enter
information or data into your program.

     One of the common mistakes by new programmers is the
recognition of alpha characters. For example, you know that you
must enter a Capital A for a particular selection, but perhaps
future users would enter a small a. Can your program distinguish
the difference? or Should it?  In many cases, if you wish to
compare a set of characters for some sort of a trigger you may wish
to streamline entries so that case does not matter.

     Below is a small example of getting your program to recognize
both upper and lower case letters:

--------------Cut Here X------------------------------------------

'******************************************************
'* Program Begins                                     *
'******************************************************

  CLS
  GOSUB PASSWORD
  IF FLAG=1 THEN GOSUB MAINPROGRAM
  IF FLAG=0 THEN LOCATE 2, 5: PRINT "Password Wrong...Exiting....."
  IF FLAG=0 THEN FOR i= 1 TO 3000: NEXT i
  IF FLAG=1 THEN LOCATE 2, 5: PRINT "Goodbye, Mr. "; pass$
  SYSTEM

'*******************************************************
'* A sample to check to see if a password is           *
'* acceptable.                                         *
'*******************************************************

password:
  DO
    CLS
    INPUT "Enter Name: ", Pass$
    IF UCASE$(pass$) = "JOE HOCHSTUHL" THEN FLAG=1: EXIT DO
    x = x + 1
    IF x = 3 THEN EXIT DO
  LOOP
  RETURN

mainprogram:
  '
  '     
  ' Main Body of Program..........
  '     
  '
  SYSTEM

--------------Cut Here X------------------------------------------

     What is happening here? In the first block, the program is
started with the traditional clear screen. The next gosub
statement passes control to a user input block where his/her
password is checked (in this case, the user's name).

     Before we go on to explain the password block, you'll
notice that there are a couple of flag statements listed below
the gosub statement. This is how we are going to check to see if
this user is allowed access to your program. A flag value of 0 will
deny access, whereas a flag value of 1 will allow access.

     Now control has been passed to the password block. You'll
notice we used a Do....Loop statement to avoid the use of the
dreaded GOTO statement. We clear the screen and provide for a
user input of his/her name. Whatever the user types will be
placed in the variable "pass$". The next line compares the user's
input to whatever name the programer has considered Valid. In
this statement, we used the UCASE$ command to convert the user's
input to all upper case letters. This will be compared to the
allowable name of "JOE HOCHSTUHL". Therefore if the user had
typed any of the following: Joe Hochstuhl, JOE HOCHSTUHL, joe
hochstuhl. The program would have seen this input as "JOE
HOCHSTUHL". The comparison would have been valid (or true). Upon
a true statement, the remainder of the line would have been
executed. The flag value would be set to "1", and the Do...Loop
routine would be terminated by the EXIT DO statement. The RETURN
statement after the loop would have been next, and that would
pass control to the statement immediately following the GOSUB
statement in the first block. This is where the Flag values would
have come into play.

     If an unacceptable name had been entered, the Do...Loop
routine would re-run that second block and the little X=X+1
counter would have registered one pass. After the third attempt,
the counter would have reached three, and the loop would have
exited leaving the flag value at 0, thereby denying access to
the program by this user.

     Feel free to experiment with this routine by changing the
acceptable name, or perhaps adding a second input statement that
would allow for a name and a Password. If you have any questions
about this routine, feel free to post questions either on my BBS
or on any Infonet Node or Hub in the Quick Basic Conference.

                                                --JH
