Hardware Reference
In-Depth Information
plain English and should not assume any particular level of technical knowledge
on the part of the user. The following are examples of acceptable messages:
Loading data file from disk...please wait!
Printer is not responding - please check paper supply.
Warning! Strain transducer on Channel 4 is not responding.
Keyboard entry
Keyboard input from the user will be required in a variety of applications. Such
input may take one of three basic forms summarized below:
1
Single keystrokes. Keystrokes may either be a letter, number, or punctuation
and will generally not require the use of the RETURN or ENTER key.
2
Numerical inputs (comprising one or more keystrokes terminated by
RETURN or ENTER). Each keystroke must be a number (or decimal point
in the case of floats) and the input will normally be assigned to a numeric
variable (either integer or floating point).
3
String inputs (comprising one or more keystrokes terminated by RETURN).
Each keystroke may be a number, letter, or punctuation. The string input by
the user will normally be assigned to a string variable.
Single key inputs
Single key inputs will be required in a wide variety of applications. Such inputs
can take various forms including menu selections or simple 'yes/no' confirm-
ations. In either case, it is important to make the user aware of which keys are
valid in each selection and, where the consequences of a user's input is irrevo-
cable, a warning should be issued and further confirmation should be sought.
A simple typical 'yes/no' dialogue would take the following form:
INPUT "Are you sure (Y/N) "; r$
IF r$ = "Y" THEN ... ELSE ...
This piece of code has a number of shortcomings not the least of which is that
it will accept any input from the user including a default (i.e. RETURN or
ENTER used on its own). Other problems are listed below:
•
The user may not realize that the input has to be terminated by ENTER or
RETURN.
•
A response of 'N' is not distinguished from a default (or any input other
than 'Y').
•
The routine does not allow a lower case input and the user may not realize
that the SHIFT key has to be applied.
•
If the user replies with 'YES' or 'yes', this would be equivalent to 'N'!
•
Finally, since we would probably want to use the routine at several points
within the program,
it should be coded as a procedure or user-defined
function.
A much better solution to the problem would take the following form:
REM Confirm function
DEF FNConfirm%
r$=""
f%=-1