Go with the flow and no illogical jumps

Authors

Publication

Pub Details

Date

Pages

Last month I explained how to draw a flowchart of a program by splitting it into parts. Each part corresponds to an operation performed either by the user or the computer program. This month we take that a step further and examine a way of breaking a program code into easily-understood areas.

There are three main operations performed in a program — input, processing by the computer, and output. Each of those operations has a distinct box in a flowchart and each has a distinct part in a program. If a beginner is to use the program the input section will be the longest, because of error-trapping techniques and instructions. The processing part of the program will be the longest if a technical person, such as a scientist who knows about computers, uses it.

Now to deal with methods of prompting a user to enter information into the computer and the best ways in which the computer can handle that information. With programs such as the database, which is to be constructed in this series, the screen display is very important. The computer uses the screen to display information to a user.

Many people who use programs such as database or word processors will know nothing about how a computer works or what it expects as input. The more information given to the user by a program the better. That does not mean clogging the screen with vast quantities of text. Instructions on the screen should be easy to read and well-spaced. The clear screen command should be used as often as possible to break-down information into easily-read pieces but at the same time the jump between one screen of instructions and another should be almost transparent to the user.

The text must flow naturally and there should be no illogical jumps in the instructions. That is a matter of experience but the database has been designed with clarity of instructions and prompts for inputs in mind.

The most important instructions should stand out from the rest. That can be done by liberal use of the GRAPHICS mode.

Listing one is the menu subroutine for the database. One thing people tend to forget is that they have the use of all the screen. Do not cram things into the corners or sides of a screen. Titles should be central and if there is only an INPUT prompt on the screen, a good place to put it is the top left-hand corner.

Listing one is the first module of the program. If there is a menu in a program it should be situated at the top of the code after any single or array variables have been declared, as in line 100 of listing one.

100 DIM B$(100,20)
300 IF A$="1" THEN GOSUB 2000
400 IF A$="2" THEN GOSUB 3000
500 IF A$="3" THEN GOSUB 4000
600 IF A$="4" THEN GOSUB 5000
700 IF A$="5" THEN GOSUB 6000
800 CLS
900 GOTO 200
1000 CLS
1020 PRINT TAB 12;" MENU "
1030 PRINT AT 5,7;"1 SEARCH FILE ";AT 7,7;"2 DISPLAY FILE ";AT 9,7;"3 LOAD FILE ";AT 11,7;"4 SAVE VILE ";AT 13,7;"5 CREATE FILE "
1035 PRINT AT 18,5;" ENTER OPTION (1-5) "
1040 INPUT A$
1050 IF A$="" THEN GOTO 1040
1060 RETURN

The menu module will display the options available from the program; ask which you require, put the number of the option selected in a string variable A$, and transfer to the control program, also in listing one, at the top of the code. The control program, consisting of a series of IF . . . THEN instructions, will then transfer to the subroutine selected from the menu.

The two other modules which are listed in this article are for LOADing data files — listing two — and SAVEing files — listing three.

4000 REM LOAD ROUTINE
4010 CLS
4015 PRINT AT 0,0;"NAME FILE TO BE ENTERED "
4018 INPUT C$
4030 IF C$=" " THEN GOTO 4010
4040 PAUSE 10
4042 CLS
4045 PRINT AT 0,0;"SET UP TAPE AND PRESS ENTER"
4050 PAUSE 40000
4060 LOAD C$
4070 PRINT AT 0,0;"FILE LOADED "
4080 PAUSE 100
4090 RETURN

The displays in both the SAVE and LOAD routines are important. Error messages should be displayed in the same position on the screen every time they appear. Every program should have a standard error message area to which the user will become accustomed. In the case of the database, that is in the middle of the screen.

5000 REM SAVE ROUTINE
5005 CLS
5010 PRINT AT 0,0;"ENTER FILE NAME "
5012 INPUT C$
5015 IF C$="" THEN GOTO 5012
5030 PAUSE 10
5032 CLS
5035 PRINT AT 0,0;"SET UP AND PRESS ENTER"
5037 PAUSE 40000
5040 PRINT " FILE """;C$;""" BEING SAVED"
5050 SAVE C$
5060 PRINT " FILE """;C$;""" SAVED"
5070 PAUSE 100
5080 CLS
5090 RETURN

The prompts and information in the SAVE and LOAD routines may seem simple and not worthwhile but the writer knows about the in¬ ternal workings of the program and what to enter. A newcomer to a program, on the other hand, needs to be taken through it step by step.

When a module of a program has been written it is a good idea to test it on a friend or relative who knows nothing about computers. If they can follow the prompts, leave the display as it is; if they are confused, you know you have more writing.

I have now shown how the database is controlled using the menu and how to ease a user’s task in getting through the program.

Products

 

Downloadable Media

 
Scroll to Top