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 Statements (Assignment) Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'These two examples use the KEY statement to assign values to soft keys.
'This is an example of assigning and disabling a soft key. KEY LIST
'displays key values after soft key 4 has been assigned and again after
'it has been disabled.
CLS 'Clear screen.
KEY 4, "MENU" + CHR$(13) 'Assign to soft key 4 the string "MENU"
'followed by a carriage return.
KEY LIST
KEY 4, "" 'Disable soft key 4.
KEY LIST
'This example uses the KEY statement 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