•
•
•
SCreen
Output
Suppose that
we
wish
to
create the
file,
numbers,
on
a cartridge
in
Microdrlve
1.
The
device name
is:
mdv1
and the appended information
is
Just
the name
of
the
file:
numbers
So
the complete
file
name
IS:
mdv1
numbers
It
is
possible for a program
to
use
several
files
at
once, but
it
IS
more convenient
to
refer
CHANNELS
to
a
file
by an associated channel number This can be any Integer
in
the range 0
to
15.
A
file
is
associated
with
a channel number by using the OPEN statement
or,
if it
IS
a new
file,
OPEN_NEW.
For
example
you
may choose channel 7 for the numbers
file and
write:
OPEN
NEW
#7 ,mdv1
numbers
1
-
I
1-
~flle
device
channel number
---------~
keyword
You
can now
refer
to
the
file
just by quoting the number #
7.
The complete program
is:
100
REMark SimpLe
fi
Le
110
OPEN
NEW
#7,
mdv1
numbers
120
FOR
number = 1
to
100
130
PRINT
#7,
number
140
EN
D
FOR
numbe r
150
CLOSE
#7
The PRINT statement causes the numbers
to
be
'printed'
on
the cartridge
file
because
# 7 has been associated
with
It.
The CLOSE # 7 statement
is
necessary because the
system
has some
internal
work
to
do when
the
file
has been used.
It
also
releases
channel
7
for
other possible
uses.
After the program has executed type:
DIR
mdv1
and the
dICectory
should show
that
the
file
numbers
exists
on the cartridge
In
Mlcrodrive
rndv1_.
You
also need
to
know that the
file
IS
correct and you can only be certain
of
this
if
the
file
is
read and checked. The necessary keyword
IS
OPEN_IN,
otherwise the program
for reading data from a
file
is
similar
to
the prevIous
one.
100
REMark
Reading
a
fi
Le
110
OPEN
IN
#6,
mdv1
numbers
120
FOR
item
=1
TO
100
130
INPUT
#,
number
140 PRINT
I number I
150
END
FOR
item
160
CLOSE
#6
The program should output the numbers 1
to
100,
but only
If
the cartridge containing
the
file
numbers
IS
still
in
Microdrive
mdv1_.
You
have seen one example
of
a device, a
file
of
data on a Microdrive.
We
may
say,
loosely,
that
a
file
has been opened but
strictly
we
mean
that
a device has
been
associated
with a particular channel. Any further necessary information has
also
been provided.
Certain deVices have channels permanently associated with them
by
the
system:
DEVICES
AND
CHANNELS
12184
channel
#0
#1
#2
use
OUTPUT
- command window
INPUT - keyboard
OUTPUT - print window
LIST
- list output
67