EasyManua.ls Logo

Commodore Plus 4 - Page 182

Commodore Plus 4
464 pages
Print Icon
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...
170
Some
Programming
Techniques
Use
CHR$
codes
in
the
definition
to
use
quotation
marks
or
a
key
such
as
a
return
or
the
ESCape
key.
STEP
3
Verify
the
new
definition
by
issuing
a
KEY
command,
which
displays
a
list
of
current
key
definitions.
Examples:
KEY
1//INPUT//+CHR$(34)
Displays
INPUT".
KEY
6/TIST"+CHR$(13)+mUN"+CHR$(13)
Issues
a
LIST
command
and
a
RUN
command.
RUN
executes
as
soon
as
the
program
is
listed.
KEY
3,CHR$(27)+"TLIST"+CHR$(
13)
Creates
a
screen
window,
whose
top
left
corner
is
the
current
cursor
loca
tion
and
whose
bottom
is
the
lower
right
corner
of
the
screen.
After
the
window
is
set,
a
LIST
command
is
issued.
Calling
a
Function
Key
During
Program
Execution
The
function
key
definition
procedure
for
defining
keys
in
immediate
mode
can
also
be
used
in
a
program.
INPUT
can
be used
to
accept
function
key
definitions.
Of
course,
the
input
must
end
with
a
RETURN
character
from
the
definition
or
the
keyboard.
GETKEY
receives
only
the
first
letter
of
the
definition.
Also,
if
GETKEY
is
called
a
second
time
following
the
receipt
of
a
multiple
character
function
key
definition,
an
error
results.
To
be
able
to
use
a
function
key
in
a
GETKEY
command,
you
must
first
redefine
the
key
as
a
single
CHR$
code.
This
definition
allows
BASIC
to
consider
the
function
key
to
be
a
single
key,
not
a
string
of
characters.
Once
the
key
is
defined
as
a
single
key,
you
can
press
the
key
as
input
for
a
GETKEY
command.
Then
you
can
use
an
IF
command
to
see
if
the
key
pressed
equals
the
CHR$
code
for
the
function
key
and
use
a
THEN
clause
to
perform
the
desired
operation(s).
The
following
example
redefines
function
keys
2
and
3
to
change
screen
colors,
switch
to
graphic
mode
1,
and
draw
a
painted
shape.
Note
that
redefinitions
written
in
a
program
are
still
in
effect
when
the
program
ends.
To
restore
the
original
definitions,
press
the
reset
button.
10
REM
DEFINE
KEYS
2
AND
3
AS
CHR$
CODES
134
AND
135
20
KEY2,CHR$(
134):
KEY3,CHR$(
135)
30
PRINT
"PRESS
P2
TO
DRAW
THE
MOON.
PRESS
P3
TO
DRAW
THE
Sim."

Other manuals for Commodore Plus 4

Related product manuals