home *** CD-ROM | disk | FTP | other *** search
- The function keys found on the IBM PC or PCjr have an almost unlimited
- number of uses. The only hard part is using them within BASIC programs.
-
- One option is to use the automatic program branching available with ON
- KEY(n) GOSUB. Most of the time this method, though, proves to be more of a
- headache than it's worth because the program exits to the function-key routine
- -no matter where you are in the program (it's interrupt-driven).
-
- The procedure outlined here will allow you to redefine the function keys
- and read then using the INKEY$ function. This not only accesses the functions
- keys, but it offers F10 as a link to even keys. by using this method, you could
- scroll through an unlimited supply of functions. When F10 is pressed, the next
- set of functions will be assigned and displayed at the bottom of the screen.
- F9 is always used as the exit key, giving the user a graceful way out of the
- program.
-
- The different functions for the functions keys are contained in a string
- array, K$(). One element of the array is used to contain information for each
- set of function keys. The array is set up in line 230 from the data statements
- in lines 320 through 360. These data statements contain the function key
- information. Because only 6 characters can be displayed on the screen for each
- function key, the size of each function redefinition will be limited to 6
- characters.
-
- The algorithm is simplifed by making all definitions the same length. In
- line 260, a simple search is made through the K$() array for valid inputs using
- the POS() function. The input is shortened to 6 characters, and the position
- of those characters is found within the active function string, K(). The
- program then checks the position for an even boundary of 6 characters within
- the string array to ensure that the information read from the buffer makes a
- full match with one of the function definitions.
-
- When F10 is pressed, line 270 checks the input for the word "NEXT ". This
- will cause a GOSUB to line 300. There, the pointer, K, into the function key
- array will be incremented. If K is larger than the largest element of the
- array, it will be reset back to 1. The next line pulls out 6 characters at a
- time from the new string of functions information, and assigns it to the
- function keys. Line 280 looks for F9 by checking for "EXIT "in the input
- buffer.
-
- By using this method, you won't need to worry about an automatic branch to
- a function routine upsetting part of your program. In addition, you can now
- use function keys in place of menus. Each function key could take you to a
- different screen, of another menu. This makes the task of designing menu
- screens easy, and offers a central area for operators to find and select the
- next step in their process.
-
- by William K. Balthrop
- keyed in by Bruce M. Almeida