home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / gwbasic / misbasic / redefkey.doc < prev    next >
Encoding:
Text File  |  1988-09-26  |  3.0 KB  |  50 lines

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