
Front
Panel
The
front
panelofthe
disk
drive
consistsofan
identification
panel
across
the
top;
slotinwhichtoinsertadiskette;
andadoortoclose
after
inserting
the
diskette.
When
the
door
is
closed,
the
diskette
is
clamped
onto
the
diskette
spindle
hub.
Alsoonthe
front
panel
are
two
LED
indicator
lights.
The
red
LED
on
the
slot
side
lights
when
driveisactive
and
flashes
wheneveradisk
error
occurs.
The
green
LED
on
the
lower
left
side
isapower
indicator
which
lights
when
powerisON.
Back
Panel
The
Back
of
the
disk
drive
contains
two
serial
interface
connectors.
Near
the
panel's
lower
edge
is
the
power
connector.
There
is
alsoa"slow
blow"
fuse.
Interior
Configuration
The
interior
of
your
floppy
contains
a
disk
drive.
All
the
logic
for
the
disk
drive
is
contained
within
the
unit.
The
mechanical
devices
are,
for
the
most
part,
located
beneath
the
disk
spindle.
The
Diskette
The
diskette
(also
known
asaminifloppy,
floppy
diskette,
minidiskette,
etc.)
is
similar
to the standard
flexible
disk.
There
are
several
reputable
manufacturers
of
the
5&-inch
diskettes.
You
should
make
sure
that
you
buy
diskettes
for
SOFT
SECTORED
FORMAT.
Your
Commodore
dealer
can
supply
your
needs.
Specifications
Table2presents
the
specifications
for
the
VIC-1540.

CAREOFTHEVIC-1540
The
disk
drive
shouldbeplacedona
flat
surface
freeofvibration.
It is
important
that
dust
particles
be
kept
ataminimum
sinceaparticle
buildup
will
interfere
with
optimum
operation.
If
you
should
experience
a
hardware
failure
contact
your
Commodore
dealer.
Any
attempt
to
correct
the
problem
yourself
could
resultinvoiding
the warranty.
CARE
OF
THE
DISKETTES
Handle
diskettes
with
care.
Follow
these
instructions
to
maintain
the
quality
of
the
diskette
and
to
protect
the
integrity
of
the
data:
1.
Return
the
diskette
to
its
storage
envelop
whenever
it is
removed
from
the
drive.
2.
Keep
the
diskettes
away
from
magnetic
fields.
Exposure
toamagnetic
field
can
distort
the
data.
3.
Never
leaveadisketteontop of
your
computerordisk
drive.
4.
Do
not
writeonthe
plastic
jacket
withalead
pencilorball-point
pen.
Use
a
felt
tip
penorfill
out
the
label
before
attaching
ittothe
jacket.
5.
Do
not
expose
diskettes
to
heat
or
sunlight.
6.
Do
not
touch
or
attempt
to
clean
the
diskette
surface.
Abrasions
will
cause
lossofstored
data.
7.
Before
applying
power
to
the
VIC-1540
open
the
drive
door
and
remove
the
diskette.
UNPACKING
THE
DISK
DRIVE
Before
unpacking
the
disk
drive,
inspect
the
shipping
carton
for
signs
of
ex
ternal
damage.Ifthe
cartonisdamaged,beespecially
careful
when
inspecting
its
contents. Carefully
remove
all
packing
material
and
the
contentsofthe
carton.DONOT
discard
any
packing
material
should
contain:
1.
VIC-1540
Single
Floppy
Disk
Drive
2.
UserMannual,
Number
1540018-02
3.
TEST/DEMO
diskette:
4.
WARRANTY
CARD
If
any
items
are
missing,
please
contact
your
Commodore
dealer
immediately.

"NEWdr:fn,xx"
or
•
"Ndrfnjcx"
Where
d=the
drive
number0(0
may
be
omitted)
fn=the
file
name
you
wishtoassigntothe
disk.Itmaybeup
to
16
characters
long.
xx=a
unique
two-character,
alphanumeric
identifier
supplied
by
the
user.
The
NEW
command
(with
ID
specified)
is
used
on
an
unformatted
diskette
or
one
which
the
user
wishestoreformat.
NEW
creates
the
block
headers,
writing
the
sync
characters,
disk
ID,
and
track
and
sector
numbers
at
the
beginning
of
each
block.
The
directory
header
and
the
BAM
are
created
and
the
diskette
is
made
readytoaccept
data.
The
command
maybeusedonan
already
formatted
diskette
(with
no
ID
specified)
to
clear
the
disk
directory
and
reinitialize
the
BAM,
deallocating
all
blocks
on
the
diskette.
The
time
involved
in
reformatting
withoutanIDismuch
less
than
formatting
withanID.
Example1:OPEN
15,8,15
PRINT#15,
"NO:TESTDISK,
88"
These
commands
will
open
the
command
and
error
channeltothe
disk
drive
and
format
a diskinthe
drive,
givingita
disk
identifer
of
88.
The
following
simplified
form
maybeused
for
this
purpose:
Example
2:
OPEN
15,
8,15,
"NO:TESTDISK,
88"
Here'sanexampleofreformatting
a diskette
using
the
NEW
command
and
no
disk
ID.
Example
3:
OPEN
1,8,15,
"NO
:NEWNAME"
The
diskette
will
be
assigned
the
name
"NEWNAME"
and
the
directory
and
BAM
will
be
cleared.
This
procedure
will
work
only
if
the
diskette
has
been
formatted.
The
NEW
disk
command
SHOULD
NOT
be
confused
with
the
NEW
command
18

Example:
PRINT#1,
"SO:ACCT,
CUSTOMER,
INV"
To
erase
several
files
at
one
time
when
names
have
something
in
common,
refer
to the
rulesinclapter8concerning,
pattern
matching.
You
may
erase
all
files
onadiskette
using
pattern
matching
as
in
the
following
example:
Example:
PRINT#1,
"SO:*"
NOTE
24

dn=is
the
device
number
and
it
must
be
8.
The
following
example
illustrates
howaprogramisloaded
from
the
diskette
into
the
computer
memory,
then
executed.
To
do
this
example,
first
type
NEW
and
depress
RETURN
keytoclear
your
computer's
memorysothat
you
can
see
that
it
really
works.
Don't
confuse
the
NEW
command
in
BASIC
with
the
NEW
disk
command
usedtoformat
your
disk.
Example1:LOAD"0:TESTPROG",
8
READY.
RUN
THISISA
TEST
A
successful
LOAD
closes
all
open
files.
Therefore
you
must
giveanew
OPEN
command
in
order
to
continue
communicating
with
the
disk
drive
command
and
error
channel.
OPEN
This
command
sets
upacorrespondence
betweenalogical
file
number
and
a
file
which
exists
on
disk.
It
also
reserves
the
buffer
space
within
the
disk
unit
for
operations
on
the
file
being
opened.
The
format
of
the
complete
OPEN
command
is:
OPENlfn,
dn,
sa,
"dr:fn,
ft,
mode"
Where:1fn=the
logical
file
number
dn=the
device
number,inthis
case
8.
sa=the
secondary
address.
It
maybeany
number
from2to14and
maybeused
either
for
inputoroutputasspecified
in
mode.
See
note
below
dr=the
drive
number
0.
(0:
may
be
omitted)
fn=the
name
of
the
file.
ft=the
file
type.
It
may
be
SEQ
(for
sequential),
USR
(for
user),
or
PRG
(for
program).
mode
describes
how
the
channel
is
to
be
used.
It
may
be
either
READ
(R)
or
WRITE
(W).
28

channels
associated
with
that
drive
are
deleted.
These
commands
should
not
be
executed
when
there
are
any
files
open
since
the
files
will
be
disrupted.
PRINT*
The
PRINT#command
transmits
a
disk
command
string
to
the
drive.
The
formatofPRINT#
is:
PRINT#lfn,
"commandstring"
Where:
lfn
=a
file
previously
opened
using
secondary
address
15
"commandstring"=disk
handling
or
disk
file
handling
commands.
These
disk
commands
are
discussedindetailinChapter3of
this
manual.
PRINT#
may
also
be
used
to
transmit
data
toapreviously-opened
sequential
or
user
file.
In
CBM
BASIC
V2
the
logical
file
number1to
127
send
carriage
return
alone
and
the
logical
file
number
128
to
255
send
CRLF.Asemicolon
(;)must
be
used
asaterminator
for
each
PRINT#
statement
when
using
the
logical
file
number
128to255toavoid
sending
extraneous
line
feedstothe
diskette.
It
is
important
to
be aware of
this
face
because
the
carriage
return
alone
is
seen
asaterminatory
by
the
DOS.
The
line
feedisthen
storedinthe
fileasthe
first
character
in
the
next
record.
To
avoid
this,
use
the
following
format:
Example:
PRINT#128,
"JONESABC";
CHR$(13);
The
CHR$(13)
is
the
carriage
return
necessary
for
the
proper
terminating
of
the
record
on
the
disk.
When
that
record
is
input,
the
result
will
be
JONESABC
whichisthe
desired
result.
The
following
format
may
that
be
used:
PRINT#lfn,A$
It
will
produce
the
desired
value
of
A$
for
the
record,
and
will
not
interfere
with
the
next
record.
Several
variables
maybewrittentothe
diskatthe
same
time.
31

The
format:
PRINT#lfn,A$,B$,C$
will
result
inasingle
variable
(A$+B$+C$)
being
retrieved
by
the
input
command.
The
format:
PRINT#lfn,A$CHR$(13)B$CHR$(13)C$
will
result
in
the
variables
A$,
B$,
and
C$
being
separated
by
carriage returns,
and
they
may
thenbeinputasseparate
variables.
INPUT*
The
INPUT#
command
is
used
to
transfer
information
fromaperipheral
device
such
as
the
disk
drive
into
computer
memory.
INPUT#is
valied
only
when
used
inaprogram
and
only
when
referencing
a
logical
file
that
has
been
OPENed
for
input.
The
format
for
INPUT*is:
INPUT#1
fn,
A$
or
INPUT#1
fn,
A
Where:
1
fn=file
previously
opened
using
secondary
address
15
A$=astring
variable
which
will
contain
the
data
transferred.
A=a
numeric
variable
which
will
contain
the
data
transferred.
INPUT
may
also
be
used
to
transfer
several
strings
of
data
at
one
time:
INPUT#lfn,A$,B$,C$
Where:
A$,
B$,
C$
will
contain
the
data
transferred
from
the
disk.
In
this
format,
the
data
strings
must
have
been
separated
by
carriage
returns
(
CHR$(13)
)
at
the
time
they
were
written
to
the
disk
in
order
to
be
retrived
separately.
No
single
string
may
contain
more
than
88
characters
if
it is
to
be
INPUT.
32

Chapter
5
ADVANCED
DISK
PROGRAMMING
This chapter
provides
detailed
information
about
DOS
structure
and
disk
utility
commands.
The
utility
commands
provide
the
programmer
with
low-level
func
tions
that
may
be
used
for
special
applications
such
as
special
disk
handling
routines
and
random
access
techniques.
COMMODORE
DISK
OPERATING
SYSTEM
(DOS)
The
DOS
file
interface
controller
is
responsible
for
managing
all
information
be
tween
the
disk
controller
and
the
serial
interface.
Most
disk
I/O
is
performed
on
a
pipelined
basis,
resulting
inafaster
response
to a
requested
operation.
The
file
system
is
organized
by
channels
which
are
opened
with
the
BASIC
OPEN
statement.
When
executed
with
the
OPEN
statement,
the
DOS
assigns
a
workspace
to
each
channel
and
allocates
either
one
or
two
disk
I/O
buffer
areas.
If
either
the
workspaceorthe
bufferisnot
available,
a
NO
CHANNEL
error
is
generated.
The
DOS
also
uses
the
channel
structure
to
search
the
directory,
and
to
delete
and
copy
files.
Three
of
the
eight
buffers
are
used
by
the
DOS
for
the
Block
Availability
Maps
(BAM),
variable
space,
command
channel
I/O,
and
disk
controller's
job
queue.
The
job
queueisthe
vital
link
between
the
two
controllers.
Jobs
are
initiated
on
the
file
sidebyproviding
the
disk
controller
with
sector
header
and
type
of
operation
information.
The
disk
controller
seeks
the
optimum
job
and
attempts
execution.
An
error
condition
is
then
returned
in
plade
of
the
job
command.
If
the
job
is
unsuccessful, the
file
side
re-enters
the
jobagiven
number
of
times,
depending
upon
the
operation,
before
generating
an
error
message.
The
secondary
address
giveninthe
OPEN
statementisusedbyDOSasthe
channel
number.
The
number
the
user
assignstoa
channelisonlyareference
number
thatisusedtoaccess
the
work
areas,
andisnot
relatedtothe
DOS
orderingofchannels.
The
LOAD
and
SAVE
statements
transmit
secondary
35

addresses
of0and
1,
respectively.
The
DOS
automatically
interprets
these
secondary
addresses
as
LOAD
and
SAVE
functions.
Unless
these
functions
are
desired
when
opening
files,
avoid
secondary
addresses
of0and
1.
The
remaining
numbers,
2 through
14,
may
be
used
as
secondary
addresses
to
open
up
to
five
channels
for
data.
Special
OPEN
and
CLOSE
Statements
for
Direct
Access
The
BASIC
statement:
OPEN2,8,4,
"#"
or
OPEN2,8,4,
"#7"
opensachanneltoone
buffer,tobe
used
with
the
block
commands. The
first
available
bufferisallocatedtochannel4in
the
first
example.
The
second
exampleisan
attempttoallocate
buffer7to
the
channel.Ifthe
buffers
are
not
available,
a
NO
CHANNELS
error
conditionisgenerated.
The
explicit
buffer
allocation
canbeusedtoreserve
a buffer
for
position
dependent
code
as in
the
caseofan
execute
command.
You
can
find
the
number
of
the
allocated
buffer
by
executing
a
GET#
state
ment.
The
byte
transmitted
is
the
buffer
number.
The
only
time
you
can
get
a
buffer
numberisbefore
any
writeorread
operationtothat
buffer.
The
CLOSE
statement
clears
the
opened
channel
and
writes
the
BAMtothe
diskette
that
was
last
usedbythat
channel.Itis
recommended
thattoavoid
con
fusion,
you
limit
yourself
to accessing
one
drive
with
any
direct
access
channel.
DISK
UTILITY
COMMAND
SET
The
disk
utility
command
set
consistsofthe
following
commands:
Commands
BLOCK-READ
BLOCK-WRITE
BLOCK-EXECUTE
BUFFER-POINTER
BLOCK-ALLOCATE
BLOCK-FREE
memory-write
memory-read
memory-execute
USER
Abbreviations
B-R
B-W
B-E
B-P
B-A
B-F
M-W
M-R
M-E
U
General
Format
"B-R:"ch,dr,t,s
"B-W:"ch,dr,t,s
"B-E^'ch.dr.t.s
"B-P:"ch,p
"B-A:"dr,t,s
"B-F:"dr,t,s
"M-W"adl/adh/nc/data
"M-R"adl/adh
"M-E"adl/adh
"Ui:parms"
36

The
Ul
command
described
under
USER
is
similar
to
the
BLOCK-READ
com
mand.
BLOCK-WRITE
When
this
commandisinitiated,
the
current
buffer
pointerisusedasthe
last
character
pointer
andisplacedinthe0positionofthe
new
buffer.
The
buffer
is
then
writtentothe
indicated
blockonthe
diskette
and
the
buffer
pointerisleft
in
position
1.
The
format
"B-W:"ch;dr;t;s
is
illustrated
in
the
following
example.
Example:
"B-W:"
7;0;35;10
Writes
channel7buffertothe
blockontrack
35,
sector
10:
The
U2
command
described
under
USER
is
similar
to
the
BLOCK-WRITE
com
mand.
BLOCK-EXECUTE
This
command
allows
partofthe
DOSoruser
designed
routinestoresideondisk
andbeloaded
into disk
drive
memory
and
executed.
B-EisreallyaB-R
with
an
addition.
The
File
Interface
Controller
begins
executionofthe
contents
after
the
blockisread
intoabuffer.
Execution
mustbeterminated
withareturn
from
the
subroutine
(RTS)
instruction.
Future system
extensions
or
user-created
func
tions
may
implement
this
command.
The
format
"B-E:"ch;dr;t;s
is
illustrated
in
the
following
example.
Example:
"B-E:"6;0;l;10
Readsablock
from
track1,sector10into
channel6buffer
and
executes
its
contents
beginning
at
position
0
in
the
buffer:
BUFFER-POINTER
This
command
changes
the
pointer
associated
with
the
given
channel
toanew
value.
This
is
useful
when
accessing
particular
fields
ofarecord
inablock
or,
if
the
block
is
divided
into
records,
individual
records
may
be
set
for
transmitting
or
receiving
data.
39

The
format
"B-P:"ch,p
is
illustrated
in
the
following
example.
Example:
"B-P:"2;l
Sets
channel2pointer
to
the
beginning
of
the
data
area
in
the
direct
access
buffer:
BLOCK-ALLOCATE
The
appropriate
BAM
is
updated
in
the
DOS
memory
to
reflect
the
indicated
block
as
allocated
(used).
In
future
operations,
the
DOS
skips
over
the
allocated
block
when
saving
programs
or
writing
sequential
files.
TTie
updated
BAM
is
written
to
diskette
upon
the
closure
ofawrite
file
or
the
closure
ofadirect
access
channel.
If
the
block
requested
has
been
previously
allocated,
the
error
channel
indicates
the
next
available
block
(increasing
track
and
sector
numbers)
withaNO
BLOCK
error.
If
there
are
no
blocks
available
that
are
greater
in
number
than
the
one
requested,
zeroes
are
displayed
as
track
and
sector
parameters.
The
format
"B-A:"dr;t;s
is
illustrated
in
the
following
example.
Example:
"B-A:"0;10;0
Requests
that
block
(sector)
0
of
track
10
be
flagged
as
allocated
on
the
diskette.
NOTE:
The
error
channel
should alwaysbecheck
when
using
BLOCK
AL
LOCATE,sothatifthe
blockisalready
allocated,
it
will
notbeoverwritten.
If
the
block
is
allocated,
the
error
message
will
also
indicate
the
next
available
block.
Example:
INPUT#15
,EN,EM$
JET
JES
Reads
the
next
track
and
sector,
respectively,
into
ET
and
ES,
as
suming
that
lfn=15
has
been
previously
OPENed
to
the
disk
error
channel.
BLOCK
FREE
The
BAMisupdatedinmemorytofree
the
block
indicated.
The
diskisup
datedona
closeaspreviously
mentioned.
Neither
the
B-A
nor
B-F
commands
40

require
thatadirect
access
channel
be
open,
since
there
is
no
channel
relation
ship
associated
with
the
operations.
However,
if
the
BAM
is
to
be
updated
on
disk,
these
operations
should
be
used
in
conjunction
the
other
block
com
mands.
The
format
"B-F:"
dr;t;s
is
illustrated
in
the
following
example.
Example:
"B-F:"0;9;20
Freeupthe
block
(sector)20of
track
9.
MEMORY
All
three
MEMORY
commands
are
byte-oriented
so
that
the
user
may
utilize
machine
language
programs.
BASIC
statements
may
be
used
to
access
informa
tion
through
the
MEMORY
commands
by
using
the
CHR$
function.
The
system
accepts
only
M-R,
M-W,
and
M-E:
neither
verbose
spelling
or
the
use
of
the
colon
(:)
is
permitted.
Memory-Write
This
command
provides
direct
access
to
the
DOS
memory.
Special
routines
may
be
down-loaded
to
the
disk
drive
through
this
command
and
then
executed
using
the
MEMORY-EXECUTE
command
or
one
of
the
USER
(U)
commands.
Up
to
34
bytes
may
be
deposited
with
each
use
of
the
command.
The
low
byte
of
the
address
must
precede
the
high
byte
of
the
address.
The
format
"M-W:"adl/adh/nc/data
is
illustrated
in
the
following
example.
Example:
uM-W:"CHR$(00X:HR$(7X:HR$(4)CHR$(32)CHR(0)CHR$(17)-
CHR$(96)
Writes
four
bytes
to
$0700
(decimal
1792):
Memory-Read
The
byte
pointed
to
by
the
address
in
the
command
string
may
be
accessed
with
this
command.
Variables
from
the
DOS
or
the
contents
of
the
buffers
may
also
be
read
with
this
command.
The
M-R
command
changes
the
contents
of
the
error
channel
since
it
is
used
for
transmitting
information
to
the
computer.
The
next
GET#
from
the
error
channel
(secondary
address
15)
transmits
the
byte.
An
INPUT#
should
not
be
executed
from
the
error
channel
afteraMEMORY-
41

Chapter
7
RANDOM
FILE
A
random
access
fileiscreated
with
the
BLOCK
and
USER
commands
described
in
Chapter
5-Adranced
Disk
Programming.
DATA
FLOW
IN
RANDOM
FILE
In
the
random
access
file
the
data
can
notbeas
simply
writteninor
read
from
as
in
the
caseofa
sequential
file.
Itisnecessarytounderstand
the
data
flow
between
the
computer,
buffer
and
disk
driveinordertotransfer
the
datainthe
random
access
file.Itcanbeillust
ratedasFig.
6.
Channel
5
OPEN
5,8,15
PRINT#5,"B-W";3;0;6;4
Transfer
the
data
from
the
buffer
to
the
computer
Channel
3
OPEN
4,8,3,
"#7"
PRINT
#4,
A$;
CHR$(44)I;
CHR$(13)
Writeinthe
data
from
the
computer
into
the
buffer
move
the buffer
pointer
PRINT#5,"B-P"3;120
»
i
Disk
Drive
Buffer
Computer
f
\
move
the
buffer
pointer
PRINT#5,"B-P"3;120
Transfer
the
data
from
the
disk
to'
the buffer
Read
in
the
data
from
the
buffer
to
the
computer
PRINT#5,"B-R";3;0;6;4
INPUT
#4,
A$,
I
Fig.
6.
Data
Flow
between
Computer,
Buffer
and
Disk
Drive
53

STEP
5.
Transfer
the
data
from
the
disk
to the
buffer
PRINT#5)"BTR:"3;0;6;4
Logical
File
Number
of
(A/
Read
Out—I
L-
Sector
Number
Track
Number
Drive
Number
Channel
Number
of
STEP
6.
Move
the buffer pointer
PRINT
#5,
"B-P:"
3;
120
Logical
File
Number
of
®J
-Pointer
Position
Channel
Number
of
(B)
Setting
of
Block
Pointer
STEP
7.
Take
out
the
data
from
the buffer
INPUT#4,A$,1
Logical
File
Number
of (By
Variables
EXAMPLE
OF
USING
RECORD
NUMBER
More
practical
program
which
uses
variables
will
be
as
follows:
It
assumes
OPEN
15,
8,
15
and
OPEN
CH,
8,
CH,
"#"
and
uses
Ul
and
U2
instead
of
B-W
and
B-R.
5166
5185
516S
5110
5120
5130
5140
5150
5160
5180
5190
REN
***'**3|e*#***#*sl**#******
REM*FDD
BLOCK
REflD
*
REM
*#*#**#***#**#*♦*******
GQSUB5330
print#i5,"U1:";ch;fb,ft/fs
print#15/"b-p:";ch;fp
GOSUB5270
FORFI=1TOFX
IHPUT#CH,FB$(FI.):
NEXT
RETURN
55

520©
REM
*#*************♦*****•+•*
5281
REM*FDD
BLOCK
WRITE
*
5292
REM
******♦♦**#***♦***+•+***
5210
G0SUB5339
5220
PRINT#15
>"B-P
=";CH;
FP
5230
FORFI=1TOFX:
PRIHT#CH,
FBI-<FI
>■;
£HR*<13),=NEXT
5240
PRINT*15>"U2:";CH;FD;FT;FS
5250
GOSUB5270
5260
RETURN
5270
REM
♦**♦**♦+**♦*****♦•*♦*♦•**
5275
REM
*
ERROR
CHECK
*
527S
REM
**###♦**♦***#***#**♦***
5280
INPUT#15,EN,EM*,ET,ES
5290
IFEN=0THENRETURN
5390
PRINT"ERROR
STflTUS:",EN;EM*;ET;ES
53101HPUT"CONTINUE?">V*:IFY$="V"THEHRETURN
5320 STOP
5322
REM
**##******#*#**********
5324
REM*SET
TRflCK&SECTOR
*
5326
REM
***********************
5330
IFF<358THENF1=0:F2=22
=
F3=1=GOTO5370
5340
IFF>357RNDF<471TRENF1=357:F2=20
=
F3=19:GOTO5370
5350
IFF*>471RNDFO88THENF
1=4?1-F2=19:
F3=25:
G0T03378
5360
IFF>580THENF1=580:F2=18:F3=31
5370
FT=INT<<<P-F1)-1>/<F2-1))+F3
5380 FS=F-F1-<FT-F3)*F2+<FT-F3-1)
5390
RETURN
Where:
CH=Channel
number
FD=Drive
number
FP=Buffer
pointer
The
line
numbers
5270
to
5320
in
the
above
are
the
error
check
routine.
Also
indicated
in
above
by
GOSUB
5330
isasubroutine
which
is
for allocating a
sectorinthe
disk.
A
track
and
sector
mustbedesignated
in
the
random
access
whichisrather
troublesome
and,
therefore,
a
concept
of
record
number
is
used
here
to
reduce
the
burden
of
the
programmer.
For
example,
serial
numbers
as
shown
in
Table
below
are
assignedtothe
sector0in
the
track1to
the
sector16of
the track
35,
in
VIC-1540.
These
serial
numbers
are
called
as
the
record
number,
which
is
in-
56

dicated
byFin
the
subroutine
starting
from
the
line
number
5330
in
the
above
example.
WhenaF
number
is
designated
and
this
subroutine
is
called,
the
corres
ponding
track
and
sector
are
allocated
automatically.
The
directory
will
not
be
destructed
as
the
track
18
has
been
avoided.
Table
10.
Allocation
of
Record
Number
Track
Number
1to17
18
to
24
25to30
31to35
Sector
0to20
Oto
8
0tol7
Oto
16
Number
of
Sector/Track
21
19
18
17
Record
No.
1-357
358471
478-579
586-664
EXAMPLE
OFARANDOM
FILE
PROGRAM
A
simple
program
has
been
made
using
method
to
createarandom
access
file
described
above.
This
program
can be used
for
the
preparation,
deletion
and
inquiry
of
an
address
list.
Line
number
line
number
line
number
Line
number
Line
number
line
number
50
100
200
300
5100
5200
-
76
-
190
-
280
-
390
-5190
-5260
Job
menu.
Creationoffile
Making
deletion
to
the
file
Search
processirig
File
input
routine
File
output
routine
16
REM
******♦****##*****#**#*
12
REM*RRNDOM
FILE
EXRMPLE
*
14
REM
##*#♦##♦♦*♦#*♦♦#**#*#**
16
BIMI$<664>:FD=
18
PRINT'TMW-
20
PRINT"
BINSERT
DRTfl
SHEETS"
22
PRINT"
:
";
24
PRINT"WW
STflRT
PRESS
rS'B"
26
GETP*:IFP*O"S"THEN26
28
0PEN15,8,15,"16":0PEN2,8,2,"#'
38
PRINT"3M-
II
>
32
PRINT"INDEX
FILE
OPERATION"
34
PRINT"
57

36
INPUT"W
MEN
SHEET?
NIMH"
;0$=PRINT'S"
38
IF0*="N"THEN46
48
IF0*O"V"THEN36
42
PRINT:PRINT"
WflIT!":FORI=1TO664
44
PRINT"
>fr
»§mm*M*Mf.
45
PRINTI*
<I>
=NEXT:GOTO50
46
OPEN5,8,5,"0:INDEX,S,R
4?
FORI=1TO664:INPUT#5,
4S
PRINT"
»TXtiMRl«}!MO»»ai»
49
NEXTI:CLOSES
56
PRINT
'TM
52
PRINT"
JOE MENU
54
PRINT"
56
PRINT
53
PRINT"
60
PRINT"
62
PRINT"
IIISII"
I;:I$< I
>='V"
IB91B!"
I;
I$<
I)
l=CREfiTE"
2=DELETE"
3=SEP.RCH"
0=ENH"
64
PRINT"
65
PRINT
66
INPUT"1
,2,3,0
1UM";O*
68
IFO$="0"THENCLOSE15:CLOSES:CL0SE2:END
70
IFO*="1"THEN104
72
IFO*="3"THEN300
74
IFO*O'"2"THES50
76
GOTO200
100
REM
♦*#*#*♦#***♦******♦***#
102
REM*MflSTER
FILE
CREflTE
♦
103
REM
*#*****#*#**#***♦♦*#***
104
PRINTMBW
";
105
PRINT"
MflSTER
FILE
CREflTE"
106
PRINT"
"
107
INPUT"IRECORD
NO.=0IIIB";F
109
IF
F=0THEN170
110
IHPUT'NflME
=.IHI";FB$<1)
120
INPUT"RDDRESS
«.IMH";FB*<2>
130
INPUT"ZIP
=.III!",FEJ(3>
132
INPUT
"TEL
a.HM";FB*<4)
134
INPUT'COMMENT
=.IM!";FB$<5>
140
GOSUB5200
150
58

160
GOTO104
170
OPENS,8,5,"80=INDEX,S
M"
175
FORI=1TO664:PRINT#5,I$<I);CHR*<13);
180
PRINT"
WUUHMKHDM»l»ftUR
IT!
IHIII"
I;I$
< I >
185
NEXT:CLOSES
196
G0T074
200 REM
***********************
201
REM
*
MflSTER
FILE
DELETE
*
202
REM
*********************+*
210
PRINT"
ZtiM
■
"
•■
212
PRINT"
MflSTER
FILE
DELETE"
214
PRINT"
"
PRINT
220
INPUT"iRECORD
NO.=031153",
F
230
IFF=QTHEN260
'235
IFI*<F)O"1"THEN220
240I*<F)
=" /"■PRINT"
WKECORD
NO."
F;"
DELETES"
250
GOTO220
260
OPENS,8,5,"SO:INDEX,£,1*1"
265
FOR
I=1T0664:
PRINT#5,1
i-
(I);
CHR*<13
>;
276 PRINT"
*!lS»M?I»W»*Si»lJH
IT!
IllSai"
I;I$<I)
275
NEXT:CLOSES
280
GOTG50
300
REM
***********************
301
REM
*
FILE
SEflRCH
*
302
REM
***********************
310
PRINT
".KM
-";
312
PRINT"
SEflRCH
314
PRINT"
":
PRINT
320
INPUT"1RECORD
NO.=SIIIB'SF
321
IFF=0THEN50
322
IFI$(F)O"1"THEN320
325
GOSUB5100
360
PRINT"NRME=";FB*<1)
370
PRINT"flDDRESS
=
";FB*<2>
330
PRINT"ZIP
=
";FB$<3>
382
PRINT"TEL
=
";FB$<4>
383
PP.INT
"COMMENT=";FB$<5)
385
PRINT"
"
390
GOTO320
59

51S6
REM
******************+**+*
5185
REM*FDD BLOCK
RERL
*
5168
REM
*♦♦*♦**********♦*****+*
5116
G0SUB5330
5120
PRINT#15,
"Ul:
",CH.;FD,F7;F5
5136
PRIHT#15,"B-
P;",CH,FP
5140
G0SUB5276
5150
FGRFI=1TOFX
5160
1HPUT#CH..FB$(FI):
51S0
NEXT
5190 RETURN
5209
REM
#.#*♦**#********♦*#*****
5201
REM*FDD-BLOCK
WRITE
*
5202
REM
#******#*******♦*******
5210
GOSUB5330
5220
PRINT#15,"B-P:";CH;
FP
5230
FORFI=1TOFX=PRINT#CH,F£$<FI);CHR$<13)>
■NEXT
5240
PRINT#15,"U2:"iCH;FD;FT;FS
525Q
GOSUB5270
5260
RETURN
5270
REM
******************#****
.5275
REM
*
ERROR
CHECK
*
527S
REM
********#****♦♦♦♦******
5280
INPUT#.l
5..
EH,
EM*
.•
ET,
ES
5296
IFEN=0THENRETURN
5360
PRINT"
ERROR
STflTUS:"
.■
EH;
EM*;
ET;
ES
5310
INPUT'-CONTINUE?";'f't
=
IFV$="V"THENRETURN
5320 STOP
5322
REM
**********if:********+if:*+
5324
REM*SET
TRflCK&SECTOR
*
5326
REM
#*#**#**♦****♦*********
5330
IFFC358THEHF1=0:F2=22
=
F3=1:GOT05378
5340
IFF>357FlHIiF<471THEHFl=357:
F2=20
'•
F3=19:
GOTO5370
5350
IFF>471fiHDF<580THENFl=471:F2=19:F3=25:GOTO5370
5366
IFF>580THENF1=589
=
F2=18:F3=31
5370
FT=INT<
<<P-F1>-1)/(F2-l))+F3
5380
FS=F-F1-<FT-FS)*F2+(FT-F3-1>
5330
RETURN
60

61:
FILE
NOT
OPEN
This
message
is
.generated
whenafile
is
being
accessed
that
has
not
been
opened
in
the
DOS.
Sometimes,
in
this
case,amessage
is
not
generated;
the
requestissimply
ignored.
62:
FILE
NOT
FOUND
The
requested
file
does
not
exist
on
the
indicated
drive.
63:
FILE
EXISTS
The
file
nameofthe
file
being
created
already
existsonthe
diskette.
64:
FILE
TYPE
MISMATCH
The
file
type
does
not
match
the
file
typeinthe
directory
entry
for the
requested
file.
65:
NO
BLOCK
This
message
occursinconjunction
with
the
B-A
command.Itindicates
that
the
blocktobe
allocated
has
been
previously
allocated.
The
para
meters
indicate
the
track
and
sector
available
with
the
next
highest
number.
If
the
parameters
are
zero
(0),
then
all
blocks
higher
in
number
areinuse.
66:
ILLEGAL
TRACK
AND
SECTOR
The
DOS
has
attemptedtoaccessatrackorsector
which
does
not
exist
in
the
format
being
used.
This
may
indicate
a
problem
reading
the
pointer
to
the
next
block.
67:
ILLEGAL
SYSTEM
TORS
This
special
error
message
indicates
an
illegal
system
trackorsector.
70:
NO
CHANNEL
(available)
The
requested
channel
is
not
available,
or
all
channels
are
in
use.Amaxi
mum
of
five
sequential
files
may
be
opened
at
one
time
to the
DOS.
Direct
access
channels
may
have
six
opened
files.
71:
DIR
ERROR
The
BAM
does
not
match
the
internal
count.
There
isaproblem
in
the
BAM
allocation
or
the
BAM
has
been
overwritten
in
DOS
memory.
To
correct
this
problem,
reinitialize
the
diskette
to
restore
the
BAM
in
memory.
Some
active
files
may
be
terminated
by
the
corrective
action.
NOTE:
BAM=Block
Availability
Map
72:
DISK
FULL
Either the
blocks
on
the
diskette
are
used
or
the
directory
is
at
its
limit
of
65

144
entries.
73:
CBMDOSV2.6V170
The
DOS
version
of
the
VIC-1540
is
2.6.
DOS
2.6
and
1.0
(CBM2040/
3040)
are
read
compatible
but
not
write
compatible,
that
is,
the
disk
formatted
on
DOS1.0
may
be
read
but can not
be
written
upon
with
VIC-
1540,
and
the
disk
formattedonDOS2.6
mayberead
but
can
not
be
written
upon
with
DOS
1.0.
DOS2.6
and
2.0
(CBM4040)
are
read
and
write
compatible,
that
is,
the
disk
formattedoneither
version
mayberead
and
written
upon
with
the
other
version.
DOS2.6
and
2.5
(CBM8050)
are
not
read
or
write
compatible,
that
is,
the
disk
formatted
on
either
version
can
not be
readorwritten
upon
with
the
other
version.
This
errorisdis
played
wheneveranattemptismadetowrite
uponadisk
which
has
been
formattedina
non-compatible
format.
This
message
may
also
appear
after
power
up.
74:
DRIVE
NOT
READY
An
attempt
has
been
madetoaccess
the
VIC-1540
Single
Drive
Floppy
Disk
without
any
diskette
presentinthe
drive.
PATTERN
MATCHING
Pattern
matchingoffile
namesisavailable
on
all
Commodore
floppys.
Pattern
matching
uses
the
question
mark
(?)
and
the
asterisk
(*)
to
perform
operations
on
several
files
with
similar
names.
The
asterisk
is
used
at
the
end
ofastring
of
characters
to
indicate
that
the
rest
of
the
name
is
insignificant.
For
example:
could
refertofiles
named
or
or
or
FIL*
FIL
FILE1
FILEDATA
FILLER
or
any
other
file
name
starting
with
the
letters
FIL.
The
question
mark
may
be
used
anywhere
within
the
string
of
characters
to
in
dicate
that
the
character
in
that
particular
position
should
be
disregarded.
For
example:
66

?????
.SRC
could
refer
to
files
named
TSTER.SRC
or
DIAGN.SRC
or
PROGR.SRC
but
not
SRC
.FILES
Both
the
characters
and
the
position
of
the
characters
are
significant.
The
question
mark
and
asterisk
maybecombinedinmany
ways:
does
not
make
sense
because
the
question
marks
areinan
area
whichisinsignifi
cant
(because
of
the
asterisk).
P???FIL*
will
access
files
with
the
names
PET
FILE
or
PRG
FILE-32
or
POKEFILES$$
or
any
other
files
starting
withPand
having
FIL
in
positions
5-7.
SCRATCH
with
pattern
matching
should
be
used
carefully,
since
multiple
files
will
be
scratched.
LOAD
will
load
the
first
file
which
fits
the
pattern
matching.
OPEN
with
pattern
matching
maybeusedtoopenanexisting
file,inwhich
case
the
first
existing
file
encountered
which
fits
the
description
willbeopened.
However,
OPEN
should
notbeused with
pattern
matching
when
creating
a
new
file.
Never
use
RENAME,
SAVE,orCOPY
for
pattern
matching
sinceanerror
condition
will
result,
if
attempted.
67

I.DIR
4
0PEN2,8,15
5
PRINT"33":G0T0
10000
10
20
4u
GET#l,fi*,B*
59
C=8
60IFfl$OIIU
THEN
C=fiSC<R$)
70IFB$O1M1
THEN
C=C+flSC<B$)*256
80
PRINT"flia"MID$<STR$<C),2);TRB<3>;
"S2"i
90
GET#1>B$:IF
STO0
THEN 1000
1U0IFB*OCHR$<34>
THEN
90
110
GET#1,B*=IF
B$OCHR$<34)THEN
PRINTED;-GOTQlID
120
GET#1,B$:IF
B*=CHR$<32)
THEN
120
130
PRINT
TflB<18);:C$=IMI
140
C$=C*+B$--GET#1,B*:IF
B$Oni1
THEN
140
150
PRINT"Iia11LEFT$<C*,3>
160
GET
T$:IF
TOO"11
THEN
GOSUB
200Q
170IFST=0
THEN 30
1000
PRINT"
BLOCKS
FREES"
1010
CLOSEl:GOTO
10000
2800IFT$="Q"
THEN
CLOSED
END
2010
GET
T$-IF
T$=""
THEN
2000
2020
RETURN
4000
REM
DISK
COMMflND
4010
C$="":PRINTI1>M;
4011
GETB$:IFB$=IM1
THEN4011
4012
PRINTB$;:IF
B$=CHR$<13>
THEN
4020
4013
C*=C$+B$:GOTO
4011
4020
PRINT#2,C$
5008
PRINT"51";
.*•.•■
5010
GET#2,fl$:PRINTfl$;:IF
fl$OCHR$(13>GOTO5010
5020
PRINT"*"
10000
PRINT
"D-DIRECTORY"
10CU0
PRINT
">-BISK
COMMflND"
•
10020
PRINT
"Q-QUIT
PROGRflM"
10030
PRINT
"S-DISK
STflTUS
"
10100
GETfi*:IFfl$=""THEN10100
10200IFfl$="D"
THEM
10
10300IFR$=".(tORfl$-">11ORfl$=">"
THEN
4000
10310IFfl$="Q"
THEN
END
1032OIFfi*="S"
THEN
5Oo0
19539
GOTO
10100
2.
VIEW
BAM
100
REM
101
REM*VIEW
BflM
FOR
VIC-1540
*
102
REM
♦*♦♦**♦*******♦**♦*♦*******
105
0PEN15,8;15
110
PRINTtlS/'^^NUI^-'N/fl
N/fl N/fl
N/fl
N/fl":Z4=l
120
0PEN2,8,2/'#"
138
v$
148
X$
150
DEF
FNS<Z>=2t<S-INT<S/8>*8>
RND
<SB<INT<S/8>>)
70

160
PRINT#15,"Ui:";2;0;i8;0
170
PRINT#J5,"B-P";2;l
1S0
PRINT11:!1;
19Q
V=22:X=l:GOSUB430
280
FORI=0TO20:PRINT:PRINT"mMRIGHT$<STR$<I)+"
",3>;:NEXT
210
GET#2,flS
■
220
GET#2,fl$
230
GET#2,fi*
240
TS=0
250
FORT=1TO17:GOSUB450
266
V=22:X=T+4:GOSUB430:GOSUB540:NEXT
278
FORI=1TO2000:NEXT
=PRINT"3"
286
V=22:X=l:GOSUB430
290
FORI=0TO20
=
PRINT•PRINT11T]I1RIGHT$<STR$<I)+11
",3);
:NEXT
300
F0RT=18T035
310
GOSUB450
320
V=22:X=T-13:GOSUB430•GOSUB540•NEXT
330
FORI=1TO1000-NEXT
34Q
print"jmmr
350
PRINT#15/'B-P";2;144
360
N*=IMI
:FORI=lTO20:GET#2,fl$-N$=N$+fl*:NEXT
376
PRINT"
"N$"
"TS-17;"BLOCKS
FREE"
3SQ
FORI=1TG4000:NEXT
330
PRINT"?]"
400
INPUT-'MUWWiaflNOTHER
DISKETTE
NIIIG";R*
410
IFfl$="V"THENRUN
420
IFWCV'THENEND
430
PRINTLEFT*<V$,V>LEFT$(X$,
X>
"II";
440
RETURN
456
GET#2>SC$:SC=RSC<RIGHT$<CHR$<0)+SC$,1)>
460
TS=TS+SC
470
GET#2,fi$:lFfl$=""THENfl$=CHR$<0>
480
SB<0)=flSC<fl$>
490
GET#2ifl*f-
IFfl$=""THENfl$=CHR$<0)
500
SB<l>=RSC<fl$>
510
GET#2>fl$:IFfl$=n"THENfl$=CHR$<0)
520
SB<2)=nSC<fl$>
530
RETURN
540
PRINT":?H"RIGHT$<STR$<T>.
1>;
"im";
550
REM
PRINTT"
"SC"
"SB<0>"
"SB<l)n
nSB<2)=CHR$<0)
560
IFT>24flNBS=13THEN:PRINTMII)*':NU^,Z4,l);
:GOTO660
570
FGRS=0TO20
530
1FT<18THEN620
590
IFT>30RNLS=17THEN:PRINTMID$<NU$.Z4,1);:GOTO660
6O0
IFT>24flNDS=13THEN:PRlNTMID*<NU^Z4>l>j
-GOTO660
610
IFT>24mNDS=19THENPRINTMID$<NU$,Z4>1);:GOTG660
620
IFT>17flNDS=20THENPRINTMID$<NU*,Z4,1);
^Z4=Z4+1:
639PRINT"a11;
640IFFNS'.:S)=0
THEN
PRINT"+M;
•G0TG66Q
659
PRINTIIB+";
:REHRIGHT$(STR$<S)/
1>;Z4,1>;
:G0T072
fA#
PRINT'TIB";
6?d
NEXT
630
RETURN
71

3.
-Dl
SPLAY
T
& S
100
REN******************************
110
REM*
DISPLRV
flNV
TRfiCK%SECTOR
*
120
REM*ONTHE
VICTOTHE
SCREEN
*
130
REM*ORTHE
VIC PRINTER
*
140
REM******************************
150
print":hm
••;
160
print»displrv
block
contents";
163
PRINT"
"••
170
REM******************************
180
REM*
SET
PROGRRM
CONSTflNT
*
130
REM******************************
200
SP$="
":NL*=CHR*<0):HX$»"0123456789RBCDEF"
210
FS$=""-F0RI=:64
TO
95:FS$=FS$+"Sl'+CHR$a>+11!"
'NEXT
I
220
SS*="
"-FOR
1=192TO223'SS*eSS$+"Sll+CHR$<I>+llI"
-NEXT
I
240 DIM
R$<15>,NB<2>
251
D*»"0"
253
PRINT"
ftKREENXIIIIIIIIIOR
XHSPWINTER"
254
OETJJflF
JJ$=""
THEN254
255IFJJ$="S"THENPRINT"
HSBBCREENSS"
256IFJJt»"P"THENPRINTu
WSIPRINTERS!11
260
0PEN15,8,15/'r'+D*'GQSUB
650
265
0PEN4,4,7"
276
OPEN
2,8,2,
"r"GOSUB
650
230
REM******************************
290
REM*
LORD
TRRCK
RND
SECTOR
*
306
REM*
INTO
DISK
BUFFER
*
310
REM******************************
320
iNPurfcirrRRCK,
sector11
;t,s
330IFT=0ORT>35
THEN
PRINT#15/lI"Di'CL0SE2-CL0SE4:CL0SE15'-PRINTllEND"-EN
340IFJJ^'S"
THEN
PRINT"»WTRRCKIIT"
SECTOR1^11*!"
341IFJJ*=»"P"
THEN
PRINT#4-PRINTS/'TRRCK'^11
SECT0RMS:PRINT#4
350
PRINTttlS/'Ul^/'DiiTiS'.GOSUBeS©
360
REM******************************
370
REM*
RERD
BVTE0OF
DISK
BUFFER
*
390
REM******************************
400
PRINT#15/'B-P:2,r'
410
PRINTftlS,"M-R"CHR$<0)CHR$(6>
420
GETttl5,fi$<0)>.IFR$<0>=IMITHENR$<0>=NL$
423IF.JJ$="S"THEN430
430IFJJ$a"P"THEN460
431
REM******************************
432
REM*
RERD&CRT
DISPLRV
*
433
REM*
RESTOFTHE
DISK
BUFFER
*
434
REM******************************
436
K»r-NBa>=RSC<R*<0>)
43Q
FOR J=0TO63-IF
J»32 THEN
GOSUB
710'IF
Z*="N"THEN
J«80-GOTO
458
440
FOR
I*K
TO 3
442
GET#2,fl*<I)-IF
fi$<I)»IMI
THEN
R$<I)«NLi
444IFK*l
RND
I<2
THEN
NB<2)*RSC<R$<D)
446
NEXT
I'K=0
449
R$=""'•B$="•"•N=J*4•GOSUB
790'
fl$*fl$+»
:
»
456 FOR
1=0TO3:N=flSC<fi*<I>>:G0SUB
790
452
C$=fl*a>'-GOSUB
850'Bt=Bf+C$
454
NEXT
I•IF
JJ$="S"
THEN
PRINTR$B$
453
NEXT
J^G0T0571
72

460
REM******************************
462
REM*
RERD&PRINTER
DISPLRY
*
464
REM******************************
466
K-fNB(l)-RSC<R$<0))
463
FOR J-0TO15
470
FOR
I»KTO13
472
0ET#2,flf(I):lF
fl$(I)-IMI
THEN
Rf<I>»Nl*
474IFK«l
RND
,I<2
THEN
NB<2>-fiSC<fl$<I>>
476
NEXT
l'.K«e
478
R*«"H•
B*«"■":N-J*16'•OOSUB
790:
fi$«fl$+"
*•
"
480
FOR
I«0TO15:H"RSC<Rt<X»'-G0SUB
790:IF
Z*»"N"THEN
J«40'GQTO
371
432
C*»R*a>:
OOSUB
850:B*«Bt+C*
434
NEXT
I
436IFJJ*-"P»
THEN
PRINT#4,fl$B$
433
NEXT
J:G0T0S71
571
REM********#*****#*******#**##«**
572
REM* NEXT
TRRCK
RND
SECTOR
#
573
REMm*mm*mmiMi***********
575
PRINT"NEXT
TRRCK
RND
SECT0Rl(NB<l)NB<2)
MM"
536
PRINT"DO
VOU
WRNT
NEXT
TRRCK
RND
SECTOR"
590
GET
Z$-IF
Z$=""
THEH590
600IFZ*-^11
THEN
T-NB(1)--S«NB<2>:GOTO330
610IFZ$=»"N"
THEN
320
620
GOTO
590
630
REM******************************
649
REM*
SUBROUTINES
*
650
REM******************************
660
REM*
ERROR
ROUTINE
♦
670
REM******************************
630
INPUT#15,EN,EM$,ET,ES-IF
EN=0
THEN
RETURN
690
PRINT"3DISK
ERRORS"EN>EM*,ET,ES
700
END
710
REM******************************
720
REM*
SCREEN
CONTINUE
MSSG
♦
730
REM******************************
740
PRINTM»MIICONTINUE<V/N>3"
750
GETZ^IF
Z*«IMI
THEN
750
760IFZ$="N"
THEN
RETURN
770IFZ$O"V"
THEN
750
780
PRINT'TJTRRCK11
T"SECTOR"S
"T'RETURN
790
REM******************************
300
REM*
DISK
BVTETOHEX
PRINT
*
810
REM******************************
820
Rl=INT<N/16>:R*«fi*+MID$<HX$,Rl+l,l>
830
R2=INT<N-16*fll):fi*»fi*+MID$<HX$,fi2+l,l>
840
RisRt+SP**.
RETURN
850
REM******************************
860
REM*
DISK
BVTETORSC
DISPLRV
*
870
REM*
CHRRRCTER
♦
330
REM******************************
890IFRSCCC$><32
THEN
C*»"
"-RETURN
910IFRSC<C$X128ORRSC<C$»159
THEN
RETURN
920
C$=MID$<SS$,3*<fiSC<C$)-127>,3>:RETURN
73

4.
CHECK
DISK
1
REM
CHECK
DISK—VER
1.4
2
BN=8:REM
FLOPPV
DEVICE
NUMBER
5
DIMT<100>:DIMS<100):REri
BflD
TRflCK,
SECTOR
flRRflY
9
PRINTMBKW
";
19
PRINT"
CHECK DISK
PROGRRM"
12
PRINT"
"
20
D$="0"
39
0PEN15,DN,15
35
PRINT#15,"y"D*
45
N/i=RND<TI)*255
50
fl$="":
FORI=:1TO255
=
fl*=fl*+CHR$<255flNIKI+N/i)):
NEXT
60
GOSUB900
70
0PEN2.DN,2.II#"
80
PRINT:PRINT#2,fi$;
85
T=i:S=0
90
PRINT#15,"B-fl:"D*;T;S
100
INPUT#15,EH,EM$,ET,ES
110
IFEN=0THEN130
115
IFET=0THEN200:REM
END
120
130
134
NB=NB+i:PRINT"
CHECKED
BLOCKS"NB
135
PRINT"
TRflCK
liHI"T;"
SECTOR
IHm"S".Tl"
140
INPUT#15>EN,EM$,ES,ET
150IFEN=0THEN35
160
T(J>=T
S<-J>=S:J=J+1
165
PRINT"MWBflD
BLOCK:III",T;S"S"
170
G0T035
200
PRINT#15,"rD$
210
GOSUB900
212
CL0SE2
215
IF>0THENPRINT")Ttt»»HO
BflD
BLOCKS!
":END
217
0PEN2>DN,2,"#"
213
PRINT"W)«flD
BLOCKS","TRflCK","SECTORS"
220
FORI=0TOJ-1
230
PRINT#15,"B-fl-";D$,T<I>,S<I>
240
PRINT,,T<I),S<I)
250
NEXT
260
PRINT"M"J"BflD
BLOCKS
HflVE
BEENflLLOCflTED"
270
CLOSE2=END
900
INPUT#15,EN,EM$,ET,ES
910IFEN=0
THEN
RETURN
920
PRIkr'MHERROR
#"EN,EM$;ET;ES"3"
930
PRINT#15,"I"D*
5.
PERFORMANCE
TEST
1600
REM
PERFORMflNCE
TEST
1.1
1010
:
1020
REM
VIC-1340
SINGLE
FLQPPV
DISK
DRIVE
1630
'
1040
:
1050
OPEN
1,9,15--0PEN13,8i13
1060
LT=35
1070
LT$*STR$(LT)
74

1678
PRINT
"Ml
UNIT
HflS
PRSSED"
J689
PRINT"
PERFORMflNCE
TEST!"
1690
PRINT-W
PULL
DISKETTE
FROM"
1700
PRINT-S
DRIVE
BEFORE
TURNING"
1710
PRINT"
POWER
OFF."
1720
END
1736
•
1740
••
1750
PRINT"
MHCONTINUE
<V/N)?B";
1760
FOR
1=0TO50-GET
fl$=NEXT
1770
GET
fl$:IF
fl$-M"
THEN
1770
1780
PRTNT
R$"W"
1790IFR*="N"
THEN
END
1800IFfi$»"V"
THEN
RETURN
1810
GOTO
1760
1820
•
1830
■
1840
PRINT
CC*
1850
INPUT*
1,EN,EM$,ET,ES
I860
PRINTTRB<12)"ai'EN;EM$;ET;ES;"SM
1870IFEN<2
THEN
RETURN
1880
PR1NT"M
UNITISFRILING"
1890
PRINT"M
PERFORMflNCE
TEST"
1900
TM$-TI$:OOSUB
1750-TI$=TMi-RETURN
1910
•
1920
•
1930
PRINT-WRITING
DflTfl"
1940
FOR
I«1000TO2000'PRINT#CH,I'NEXT
1950
GOSUB1850
I960
CLOSE
CH-RETURN
1970
••
1980
*■
1990
PRINT"RERDING
DflTR"
2000 GETR*
2810
FOR
1=1008
TO 2000
2020
INPUT*
CH,J
2030IFKM
THEN
PRINT":RERD
ERROR:I"•GOSUB
1850
2040
NEXT
2050
GOSUB
1350
2060
CLOSE
CH:RETURN
76