EasyManua.ls Logo

Commodore 1581 - Page 58

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...
EXAMPLES:
To
read
a
file
that
may
contain
a
CHR$(0),
such
as
a
machine
language
program
file,
you
could
correct
any
CHR$(0)
bytes
with
1100
GET#3,G$:IF
G$
=
""
THEN
G$
=
CHR$(0)
If
an
overlong
string
has
managed
to
be
recorded
in
a
file,
it
may
be
read
back
safely
into
the
computer
with
GET#,
using
a
loop
such
as
this
3300
B$
=
""
,
3310
GET#1
A$
3320
IF
A$OCHR$(13)
THEN
B$
=
B$+A$:GOTO
3310
The
limit
for
such
a
technique
is
255
characters.
It
will
ignore
CHR$(0),
but
that
may
be
an
advantage
in
building
a
text
string.
If
CHR$
(0)
is
required
in
the
file,
then
add
the
following
line:
3315
If
A$
=
""
THEN
A$
=
CHR$(0T
GET#
may
be
useful
in
recovering
damaged
files,
or
files
with
unknown
contents.
The
BASIC
reserved
variable
ST
(the
file
STatus
variable)
can
be
used
to
indicate
when
all
of
a
properly
closed
file
has
been
read.
500
GET#2,S$
510
SU
=
ST:REM
REMEMBER
FILE
STATUS
520
PRINT
S$;
530
IF
SU
=
0
THEN
500.REM
IF
THERE'S
MORE
TO
BE
READ
540
IF
SUO64
THEN
PRINT
"STATUS
ERROR:
ST
=
";SU
Copying
ST
into
SU
is
often
an
unneccessary
precaution,
but
must
be
done
if
any
other
file-handling
statement
appears
between
the
one
which
read
from
the
file
and
the
one
that
loops
back
to
read
again.
For
example,
it
would
be
required
if
line
520
was
changed
to
520
PRINT#1,S$;
Otherwise,
the
file
status
checked
in
line
530
would
be
that
of
the
write
file,
not
the
read
file.
The
following
table
applies
to
single
errors
or
a
combination
of
two
or
more
errors.
49

Table of Contents

Other manuals for Commodore 1581

Related product manuals