Hardware Reference
In-Depth Information
Figure 6.4 Output produced by the simple menu selection routine
CASE "1"
CALL Setparams
CASE "2"
CALL Heatcontrol
CASE "3"
CALL Pumpcontrol
CASE "4"
CALL Printreport
CASE "5"
CALL Closedown
CASE ELSE
SOUND 60, 2
END SELECT
WEND
Since we are no longer testing for a valid key entry (in the form of a figure
in the range 1 to 5) we have included a 'catchall' in the form of the CASE
ELSE statement. We have also made the program a little more 'user-friendly' by
providing the user with an audible warning if an input keystroke is unacceptable.
The output produced by the program is shown in Figure 6.4.
Whilst on the topic of 'user-friendly' programs, it is perhaps worth mention-
ing that good use can be made of QuickBASIC's ability to trap key events. As
an example, let us assume that the user is to be provided with an online help
facility available from any point in the program when the F1 key is depressed.
The following steps are required:
1
Code the subroutine (in this example we shall name it Help) along the lines
described earlier in this chapter.
2
Inform QuickBASIC that the Help subroutine is to be associated with the
F1 key. The required statement is:
ONKEY(l) GOSUB Help
Search WWH ::




Custom Search