Authors
Publication
Pub Details
Date
Pages
BASIC Terms
Have you ever been frustrated with a program that had run-time errors caused by bad data, parameters, or values? Consider TOGGLING as a potential solution.
Some programs which are designed to receive data from keyboard entry endeavor to edit the entered data to prevent subsequent errors. This can be simple or complex programming, it may or may not detect all the errors and it can entail quite extensive program code to perform the edit. As an example the simple choice of a “Yes or No” option has to deal with the a sting variable of variable length, upper and lower case, and the correct characters.
e.g.
100 PRINT "Select Yes or No "
110 INPUT A$
120 IF A$ = "Yes" THEN GOTO nnnn
130 IF A$ = "yes" THEN GOTO nnnn
140 IF A$ = "YES" THEN GOTO nnnn
150 IF A$ = "No" THEN GOTO yyyy
160 IF A$ = "no" THEN GOTO yyyy
170 IF A$ = "NO" THEN GOTO yyyy
180 GOTO 100
TOGGLING, even in this simple example, may be better.
e.g.
100 LET A$ = "Yes"
110 PRINT "Select Yes or No ";A$
120 IF INKEY$ = " " THEN GOTO 120
130 IF INKEY$ = (space) THEN LET A$ = "No"
140 IF INKEY$ =(space)THEN GOTO nnnnn
150 IF INKEY$ =(return)THEN GOTO yyyyy
160 GOTO 120
The objective is to lock out the use of all keys except those that are to be used to TOGGLE the selections, one might want to modify the program to display the option available for selection or confirmation thru the use of appropriate PRINT statements. What if the options were days of the week; Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday? The number of permutations, for editing purposes, is significantly increased. TOGGLING may deal with these permutations by setting up an array with the appropriated character strings which could be index by a subscripted variable. The main purpose of this approach is to enable the programmer to, as much as possible, to establish a common subroutine for the user to select perdetermined options by use of the space key, to index the array for the correct option, and the enter key to confirm the selected option. With this approach in programming the option that has been confirmed, while it may not be correct for other reasons, it has to be acceptable to logical to the remainder of the program.
With this basic model and theory the author will leave the reader to be challanged in the exploitation or application of the model. All comments or discussion on the relative merits of TOGGLING are welcomed.