home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
Geneve
/
9640news
/
CAT10
/
CLLKYT.ARK
< prev
next >
Wrap
Text File
|
2006-10-19
|
5KB
|
191 lines
?
***********************************
* *
* THE POWER OF "CALL KEY" *
* *
* By Steve Langguth *
* Ozark 99'er Users Group *
* *
***********************************
The CALL KEY command in Basic and
Extended Basic is one whose complete
power may not be appreciated by many
programmers. This article and list of
examples is an attempt to explain some
of the "hidden" capabilities of the
CALL KEY statement so that you can get
the most out of it in your own
programs.
The information in this article
was collected from several sources
including : an excellent summary of
the CALL KEY options, written by Joyce
Corker of Waltham, Mass. (the examples
that make up the second half of this
article are completely hers) which has
appeared in several other newsletters
recently; and an article by Glenn
Davis in the January 1985 edition of
the MSP 99 Newsletter.
CALL KEY, as implemented on the
TI 99/4A has six possible modes in
which to operate. These modes are
summarized below.
CALL KEY(0,KEY,STATUS)
When the mode specified is "0",
the keyboard is scanned in the same
mode it was in previously. (The
normal Basic mode is Mode 5 --see
below-- so when a CALL KEY(0,K,S)
statement is used in Basic or Extended
Basic, we are really telling the
computer to scan using Mode 5 "just
like you were doing before".)
CALL KEY(1,KEY,STATUS)
Mode 1 scans the left side of the
keyboard only.
CALL KEY(2,KEY,STATUS)
Mode 2 scans the right side of
the keyboard only.
CALL KEY(3,KEY,STATUS)
Mode 3 is the "99/4" mode. In
this mode values for upper case
letters are returned in "KEY" even if
a lower case letter is pressed. (In
other words, in this mode it doesn't
matter whether the ALPHA LOCK key is
up or down, all you get is upper case
letters.)
This mode is particularly useful
where upper case letters are
important. For example, it is
recommended that disk file names be in
all upper case letters. By putting a
CALL KEY(3,K,S) statement before the
INPUT or ACCEPT statement, the name
typed in by the user will be all in
upper case letters. (TI Writer uses
this mode when accepting file names.)
CALL KEY(4,KEY,STATUS)
Mode 4 (Pascal Mode) allows upper
and lower case letters and all control
and function keys. However, some of
the "codes" are different than in
Basic. For example, FCTN 4 will not
"break" a program on an INPUT or
ACCEPT statement, FCTN S will not
backspace, etc. This is because these
combinations of key strokes generate
different codes in this mode than in
Basic. (See the appendix in the
User's Reference Guide.)
CALL KEY(5,KEY,STATUS)
Mode 5 is normal Basic mode and
allows for both upper and lower case
letters.
EXAMPLES
--------
Below are several examples of how
some of the modes described can be put
to use.
Yes or no answers using CALL KEY 0
100 CALL CLEAR
110 PRINT "Y OR N?"
120 CALL KEY(0,K,S)
130 IF K=78 THEN 170
140 IF K<>89 THEN 120
150 PRINT "YES"
160 GOTO 180
170 PRINT "NO"
180 END
Space bar or ENTER answers using CALL
KEY 5
100 DISPLAY AT(3,3)ERASE ALL:
"PRESS SPACE BAR TO CONTINUE" :
"PRESS ENTER TO PRINT"
110 FOR DELAY=1 TO 600 ::
NEXT DELAY
120 CALL KEY(5,K,S)
130 IF K=32 THEN PRINT "SPACE BAR
PRESSED" :: GOTO 150 ELSE
IF K<> 13 THEN 120
140 PRINT "ENTER WAS PRESSED"
150 END
Alphabet answers that are forgiving
of wrong case using CALL KEY 3
100 DISPLAY AT(3,3)ERASE ALL:
"PRESS R TO REPEAT" :
"PRESS P TO PRINT"
110 FOR DELAY=1 TO 600 ::
NEXT DELAY
120 CALL KEY(3,K,S)
130 IF K=82 THEN PRINT "HERE YOU
WOULD GOTO YOUR REPEAT
SUBPROGRAM" :: GOTO 150 ELSE
IF K<>80 THEN 120
140 PRINT "HERE YOU WOULD GO TO
YOUR PRINT SUB"
150 END
Accessing Function and Control Keys
using CALL KEY 5
100 DISPLAY AT(3,3)ERASE ALL:
"PRESS CONTROL KEY AND COMMA"
110 FOR DELAY=1 TO 600 ::
NEXT DELAY
120 CALL KEY(5,K,S)
130 IF K=128 THEN PRINT "CONTROL
AND COMMA PRESSED" ELSE 120
140 END
or
100 DISPLAY AT(3,3)ERASE ALL:
"PRESS FUNCTION 8"
110 FOR DELAY=1 TO 600 ::
NEXT DELAY
120 CALL KEY(5,K,S)
130 IF K=6 THEN PRINT "FUNCTION
8 PRESSED" :: GOTO 140 ELSE
120
140 END
As you can see, the CALL KEY
command gives you a great deal of
control over the input you are
accepting.
Download complete. Turn off Capture File.