EasyManua.ls Logo

Commodore VIC-20 - Using the GET Statement

Commodore VIC-20
308 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...
USING
THE
GET
STATEMENT
Most
simple
programs
use
the
INPUT
statement
to
get
data
from
the
person
operating the
computer.
When
dealing
with
more
complex
needs,
such
as
protection
from
typing
errors,
the
GET
statement
offers
more
flexibility
and
gives
the
program
more
intelligence.
This
section
shows
you
how
to
use
the
GET
statement
to
add
some
special
screen
editing
features
to
your
programs.
The
ViC
has
a
keyboard
buffer
that
holds
up
to
10
characters.
This
means
if
the
computer
is
busy
doing
some
operation
and
is
not
reading
the
keyboard,
you
can
still
type
in
up
to
10
characters,
and
the
VIC
will
use
them
as
soon
as
it
finishes
what
it
was
doing.
This
can
be
demonstrated
with
a
simple
program.
Type
in
the
program
shown
below.
When
you
tell
it
to
RUN,
type
the
word
HELLO
on
the
keyboard.
Since
the
VIC
is
busy
in
a
loop,
nothing
appears
on
the
screen—until
the
program
stops
after
15
seconds,
and
the
word
HELLO
that
you
typed
appears
on
the
screen.
10
Tl$
=
"000000"
20
IF
TIS
<
"000015"
THEN
20
The
VIC's
input
buffer
is
also
called
a
queue,
which
is
a
good
image
to
use
to
better
understand
how
it
works.
Imagine
standing
in
line
wailing
to
buy
a
ticket
to
get
into
a
movie.
The
first
person
in
line
is
the
first
to
get
a
ticket
and
leave
the
line,
and
the
last
person
in
line
is
the
last
to
get
a
ticket.
(In
accounting,
this
is
called
the
"first
in,
first
out"
method,
or
FIFO,
as
opposed
to
the
"last
in,
first
out",
or
LIFO
method.)
The
GET
statement
in
the
VIC
acts
as
the
ticket
taker.
First
it
looks
to
see
if
there
are
any
characters
"in
line"
(if
a
key
or
keys
have
been
typed).
If
there
are,
the
first
character
typed
gets
placed
in
a
"variable"
and
out
of
the
queue.
If
no
characters
are waiting
in
the
buffer,
then
an
empty
value
is
returned.
One
other
point
should
be
mentioned
when
talking
about
the
queue.
Any
characters
typed
on
the
VfC's
keyboard
afterthe
queue
is
fulf
are
lost,
since
the
queue
was
full.
So
imagine
that
the
ticket
line
is
long
enough
to
hold
10
people,
and
there
is
a
cliff
at
the
end
of
the
line.
Anyone
trying
to
get
into
the
line
afterthe
line
is
full
simply
falls
off
the
cliff,
never
to
be
seen
again.
Since
the
GET
statement
will
keep
going
even
when
no
character
was
typed,
it
is
often
necessary
to
put
the
GET
statement
into
a
loop,
having
it
wait
until
the
operator
hits
a
key
(actually,
until
a
character
has
been
received}.
Here
is
the
recommended
form:
(Type
NEW
to
erase
the
previous
program.)
10
GET
AS
:
IF
AS -
""
THEN
10
77

Other manuals for Commodore VIC-20

Related product manuals