EasyManua.ls Logo

Radio Shack TRS-80 Model 3 - Page 176

Radio Shack TRS-80 Model 3
276 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
TRS-80 MODEL III
INK~:Y$
Returns a one-characterstring determined by a keyboard check. The last key
pressed before the checkis returned.
If
no key has been pressed, a null string
(length zero) is returned. This is a very powerful function because it lets you input
values while the Computeris executing
--
without using the
(ENTER)
key. The
popularvideo games which let you fire at will, guide a moving dot through a maze,
play tennis,
etc.,
may all be simulated using the INKEY$ function (plus a lot
of
other
program logic,
of
course).
Characters typed to an
INKEY$
are
not
automatically displayed on the screen.
INKEY$ is often placed inside some sort
of
loop, so that the keyboard is scanned
repeatedly.
Example Program:
51..0
CLB
550
PRINT
@
540,
INKEY$:
GOTO
550
RUN the program; notice thatthe screen remains blank until the first time you hit a
key. Thelast key hit remains
on
the screenuntil you hit anotherone. (The last key
hit is always saved.
The
INKEY$
function uses it until
it
is replaced by a new value.)
INKEY$ may be used in sequences
of
loops to allow the userto buildup a longer
string.
Example:
590
PRINT
II
ENTER
THREE
CHARACTERS
II
600
AS
.-
INI·"\EY$
:
IF
AS
M'M
" "
THEN
600
ELSE
PRINT
A$;
610
Ea$
:::
IN~"\EYS
:
IF
£:,>,$
_.
II II
THEN
610
ELSE
PRINT
EaS;
620
C~l>
_M
I
NI'\EY~l;
:
IF
C$
:::
" "
THEN
620
ELSE
PRINT
C$;
630
D$
_.
AS
+
Ea$
+
C$
A three-character string D$ cannow be entered via the keyboard without using the
(ENTER)
key.
NOTE:
The statement
IF
A$
="
"comparesA$ to the null string. There are
no
spaces between the double-quotes.
5/4

Related product manuals