qb45advr.hlp (
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
KEY Statement Programming Example
◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
KEY Statement Programming Example
These examples show how to assign values to soft keys.
Here is an example of assigning and disabling a soft key. KEY LIST
displays key values after KEY 4 has been assigned and again after
it has been disabled:
CLS ' Clear screen
KEY 4, "MENU" + CHR$(13) 'Assigns to soft key 4 the string
'"MENU" followed by a carriage return.
KEY LIST
KEY 4, "" 'Disables soft key 4.
KEY LIST
Here is an example of using KEY statements to set up one-key
equivalents of menu selections. For example, pressing F1
is the same as entering the string "Add":
CLS ' Clear screen
DIM KeyText$(3)
DATA Add, Delete, Quit
' Assign soft-key strings to F1 to F3.
FOR I = 1 TO 3
READ KeyText$(I)
KEY I, KeyText$(I) + CHR$(13)
NEXT I
' Print menu.
PRINT " Main Menu" : PRINT
PRINT " Add to list (F1)"
PRINT " Delete from list (F2)"
PRINT " Quit (F3)" : PRINT
' Get input and respond.
DO
LOCATE 7,1 : PRINT SPACE$(50);
LOCATE 7,1 : INPUT " Enter your choice:", R$
SELECT CASE R$
CASE "Add", "Delete"
LOCATE 10,1 : PRINT SPACE$(15);
LOCATE 10,1 : PRINT R$;
CASE "Quit"
EXIT DO
CASE ELSE
LOCATE 10,1 : PRINT "Enter first word or press key."
END SELECT
LOOP