home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / Geneve / 9640news / CAT10 / CLLKYT.ARK < prev    next >
Text File  |  2006-10-19  |  5KB  |  191 lines

  1. ?
  2.    ***********************************
  3.    *                                 *
  4.    *     THE POWER OF "CALL KEY"     *
  5.    *                                 *
  6.    *        By Steve Langguth        *
  7.    *    Ozark 99'er Users Group      *
  8.    *                                 *
  9.    ***********************************
  10.  
  11.  
  12.       The CALL KEY command in Basic and
  13.  Extended Basic is one whose complete
  14.  power may not be appreciated by many
  15.  programmers.  This article and list of
  16.  examples is an attempt to explain some
  17.  of the "hidden" capabilities of the
  18.  CALL KEY statement so that you can get
  19.  the most out of it in your own
  20.  programs.
  21.       The information in this article
  22.  was collected from several sources
  23.  including : an excellent summary of
  24.  the CALL KEY options, written by Joyce
  25.  Corker of Waltham, Mass. (the examples
  26.  that make up the second half of this
  27.  article are completely hers) which has
  28.  appeared in several other newsletters
  29.  recently; and an article by Glenn
  30.  Davis in the January 1985 edition of
  31.  the MSP 99 Newsletter.
  32.  
  33.  
  34.       CALL KEY, as implemented on the
  35.  TI 99/4A has six possible modes in
  36.  which to operate.  These modes are
  37.  summarized below.
  38.  
  39.  
  40.       CALL KEY(0,KEY,STATUS)
  41.  
  42.       When the mode specified is "0",
  43.  the keyboard is scanned in the same
  44.  mode it was in previously.  (The
  45.  normal Basic mode is Mode 5 --see
  46.  below-- so when a CALL KEY(0,K,S)
  47.  statement is used in Basic or Extended
  48.  Basic, we are really telling the
  49.  computer to scan using Mode 5 "just
  50.  like you were doing before".)
  51.  
  52.       CALL KEY(1,KEY,STATUS)
  53.  
  54.       Mode 1 scans the left side of the
  55.  keyboard only.
  56.  
  57.       CALL KEY(2,KEY,STATUS)
  58.  
  59.       Mode 2 scans the right side of
  60.  the keyboard only.
  61.  
  62.       CALL KEY(3,KEY,STATUS)
  63.  
  64.       Mode 3 is the "99/4" mode.  In
  65.  this mode values for upper case
  66.  letters are returned in "KEY" even if
  67.  a lower case letter is pressed. (In
  68.  other words, in this mode it doesn't
  69.  matter whether the ALPHA LOCK key is
  70.  up or down, all you get is upper case
  71.  letters.)
  72.       This mode is particularly useful
  73.  where upper case letters are
  74.  important.  For example, it is
  75.  recommended that disk file names be in
  76.  all upper case letters.  By putting a
  77.  CALL KEY(3,K,S) statement before the
  78.  INPUT or ACCEPT statement, the name
  79.  typed in by the user will be all in
  80.  upper case letters. (TI Writer uses
  81.  this mode when accepting file names.)
  82.  
  83.       CALL KEY(4,KEY,STATUS)
  84.  
  85.       Mode 4 (Pascal Mode) allows upper
  86.  and lower case letters and all control
  87.  and function keys.  However, some of
  88.  the "codes" are different than in
  89.  Basic.  For example, FCTN 4 will not
  90.  "break" a program on an INPUT or
  91.  ACCEPT statement, FCTN S will not
  92.  backspace, etc.  This is because these
  93.  combinations of key strokes generate
  94.  different codes in this mode than in
  95.  Basic.  (See the appendix in the
  96.  User's Reference Guide.)
  97.  
  98.       CALL KEY(5,KEY,STATUS)
  99.  
  100.       Mode 5 is normal Basic mode and
  101.  allows for both upper and lower case
  102.  letters.
  103.  
  104.  
  105.  EXAMPLES
  106.  --------
  107.  
  108.       Below are several examples of how
  109.  some of the modes described can be put
  110.  to use.
  111.  
  112.  
  113.   Yes or no answers using CALL KEY 0
  114.  
  115.       100 CALL CLEAR
  116.       110 PRINT "Y OR N?"
  117.       120 CALL KEY(0,K,S)
  118.       130 IF K=78 THEN 170
  119.       140 IF K<>89 THEN 120
  120.       150 PRINT "YES"
  121.       160 GOTO 180
  122.       170 PRINT "NO"
  123.       180 END
  124.  
  125.  
  126.   Space bar or ENTER answers using CALL
  127.  KEY 5
  128.  
  129.      100 DISPLAY AT(3,3)ERASE ALL:
  130.          "PRESS SPACE BAR TO CONTINUE" :
  131.          "PRESS ENTER TO PRINT"
  132.      110 FOR DELAY=1 TO 600 ::
  133.          NEXT DELAY
  134.      120 CALL KEY(5,K,S)
  135.      130 IF K=32 THEN PRINT "SPACE BAR
  136.          PRESSED" :: GOTO 150 ELSE
  137.          IF K<> 13 THEN 120
  138.      140 PRINT "ENTER WAS PRESSED"
  139.      150 END
  140.  
  141.  
  142.   Alphabet answers that are forgiving
  143.  of wrong case using CALL KEY 3
  144.  
  145.      100 DISPLAY AT(3,3)ERASE ALL:
  146.          "PRESS R TO REPEAT" :
  147.          "PRESS P TO PRINT"
  148.      110 FOR DELAY=1 TO 600 ::
  149.          NEXT DELAY
  150.      120 CALL KEY(3,K,S)
  151.      130 IF K=82 THEN PRINT "HERE YOU
  152.          WOULD GOTO YOUR REPEAT
  153.          SUBPROGRAM" :: GOTO 150 ELSE
  154.          IF K<>80 THEN 120
  155.      140 PRINT "HERE YOU WOULD GO TO
  156.          YOUR PRINT SUB"
  157.      150 END
  158.  
  159.  
  160.   Accessing Function and Control Keys
  161.  using CALL KEY 5
  162.  
  163.      100 DISPLAY AT(3,3)ERASE ALL:
  164.          "PRESS CONTROL KEY AND COMMA"
  165.      110 FOR DELAY=1 TO 600 ::
  166.          NEXT DELAY
  167.      120 CALL KEY(5,K,S)
  168.      130 IF K=128 THEN PRINT "CONTROL
  169.          AND COMMA PRESSED" ELSE 120
  170.      140 END
  171.  
  172.   or
  173.      100 DISPLAY AT(3,3)ERASE ALL:
  174.          "PRESS FUNCTION 8"
  175.      110 FOR DELAY=1 TO 600 ::
  176.          NEXT DELAY
  177.      120 CALL KEY(5,K,S)
  178.      130 IF K=6 THEN PRINT "FUNCTION
  179.          8 PRESSED" :: GOTO 140 ELSE
  180.          120
  181.      140 END
  182.  
  183.       As you can see, the CALL KEY
  184.  command gives you a great deal of
  185.  control over the input you are
  186.  accepting.
  187.  
  188. Download complete.  Turn off Capture File.
  189.  
  190.  
  191.