EasyManua.ls Logo

Commodore 1581 - Reading File Data: Using GET#

Commodore 1581
138 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...
those
data
elements
to
be
read
back
into
a
numeric
variable
by
INPUT#
later,
although
file
data
errors
may
be
avoided
by
reading
all
data
in
as
strings,
and
converting
to
numbers
using
the
VAL
()
function
after
the
information
is
inside
the
computer.
For
example,
"N$
=
RIGHT$(STR$(N)J£N(STR$(N))-1)"
will
convert
a
positive
number
N
into
a
string
N$
without
the
usual
leading
space
for
its
numeric
sign.
Then
instead
of
writing
PRINT#5,N,
you
would
use
PRINT#5,N$.
READING
FILE
DATA:
USING
GET#
The
GET#
statement
retrieves
data
from
the
disk
drive,
one
character
at
a
time.
Like
the
similar
keyboard
GET
statement
in
BASIC,
it
only
accepts
a
single
character
into
a
specified
variable.
However,
unlike
the
GET
statement,
it
doesn't
just
fall
through
to
the
next
statement
if
there
is
no
data
to
be
gotten.
The
primary
use
of
GET#
is
to retrieve
from
diskette
any
data
that
cannot
be
read
into
an
INPUT#
statement,
either
because
it
is
too
long
to
fit
in
the
input
buffer
or
because
it
includes
troublesome
characters.
FORMAT
FOR
THE
GET#
STATEMENT:
GET#file#,variable
list
where
"file
#"
is
the
same
file
number
given
in
the
desired
file's
current
OPEN
statement,
and
'Variable
list"
is
one
or
more
valid
BASIC
variable
names.
If
more
than
one
data
element
is
to
be
input
by
a
particular
GET#
statement,
each
variable
name
must
be
separated
from
others
by
a
comma.
In
practice,
you
will
almost
never
see
a
GET
or
GET#
statement
containing
more
than
one
variable
name.
If
more
than
one
character
is
needed,
a
loop
is
used
rather
than
additional
variables.
Also
as
in
the
INPUT#
statement,
it
is
safer to
use
string
variables
when
the
file
to
be
read
might
contain
a
non-numeric
character.
Data
in
a
GET#
statement
comes
in
byte-by-byte,
including
such
normally
invisible
characters
as
the
Carriage
Return,
and
the
various
cursor
controls.
All
but
one
will
be
read
properly.
The
exception
is
CHR$(0),
the
ASCII
Null
character.
It
is
different
from
an
empty
string
(one
of
the
form
A$
=
""),
even
though
empty
strings
are
often
re
ferred
to
as
null
strings.
Unfortunately,
in
a
GET#
statement,
CHR$(0)
is
converted
into
an
empty
string.
The
cure
is
to
test
for
an
empty
string
after
a
GET#,
and
replace
any
that
are
found
with
CHR$(0)
instead.
The
first
example
below
illustrates
the
method.
48

Table of Contents

Other manuals for Commodore 1581

Related product manuals