Radio Shack Hardware Manual 3 Disk System Owners 1980 Tandy A Text

User Manual: manual pdf -FilePursuit

Open the PDF directly: View PDF PDF.
Page Count: 182

DownloadRadio Shack Hardware Manual  3 Disk System Owners 1980 Tandy A Text
Open PDF In BrowserView PDF
TM

Disk System Owner's Manual

TRSDOS™
Disk

Mini-Disk Operation
Disk Operating System

BASIC Programming Language

".*

.*<-?-' *>t

vv\
4

I

J

I

The

biggest

name

in little

computers

CUSTOM MANUFACTURED

IN

1

THE USA BY RADIO SHACK

C

A DIVISION OF TANDY CORPORATION

This equipment generates and uses radio frequency energy. If not installed and used properly, that is, in strict accordance with the manufacturer's instructions, it may cause interfer-

and television reception.
has been type tested and found to comply with the limits for a Class B computing
device in accordance with the specifications in Subpart J of Part 15 of FCC Rules, which are
designed to provide reasonable protection against such interference in a residential installation. However, there is no guarantee that interference will not occur in a particular
ence

to radio

It

installation.

this

If

equipment does cause interference

to radio or television reception,

determined by turning the equipment off and on, the user
interference by one or more of the following measures:
•

encouraged

which can be

to try to correct the

Reorient the receiving antenna

•

Relocate the computer with respect to the receiver

•

Move

•

is

the computer

away from

the receiver

Plug the computer into a different outlet so that computer and receiver are on different
branch circuits.

necessary, you should consult the dealer or an experienced radio/television technician for
You may find the following booklet prepared by the Federal Communications Commission helpful: How to Identify and Resolve Radio-TV Interference
Problems.
This booklet is available from the US Government Printing Office, Washington, DC
20402, Stock No. 004-000-00345-4.
If

additional suggestions.

This equipment has been certified to comply with the limits for a Class B computing device,
pursuant to Subpart J of Part 15 of FCC Rules. Only peripherals (computer input/output
devices, terminals, printers, etc.) certified to comply with the Class B limits may be attached
to this

radio

computer. Operation with non-certified peripherals

and TV reception.

is likely

to result in interference to

CHANGE OF ADDRESS
you move, please fill out this card and return
receive information regarding this program.

NOTE:

if

it

so that you may continue to
«

AfirrtlQl

Purchase Date

on

a

*JR ? /63
Cat. No.

NEW ADDRESS:

OLD ADDRESS:

Name

Name

Company

Company

Address _

Address _

City

City

Zip

State

-

.

State

Zip

INSTRUCTIONS FOR USE

1.

Register one software package per card only.

2.

Complete the Software Registration portion of this form and mail it immediately.
The Catalog No. may be found by examining the upper-right corner of your diskette.

3.

For convenience a change of address card has been included. Copy all information
from the Registration Card onto it prior to sending the Registration Card.

Model III Users

XFERSYS UTILITY ON TRSDOS 1.3
The Model III diskette in this package contains a NEW
version of TRSDOS which is not compatible with OLD versions
of TRSDOS.

OLD TRSDOS diskettes to be used under the NEW TRSDOS MUST
be XFERSYSed before use. Once XFERSYSed, an OLD TRSDOS
diskette becomes a NEW TRSDOS diskette and should not be
used with OLD TRSDOS again. If you started with an OLD
system or data diskette, the XFERSYSed diskette will be a
NEW system or data diskette respectively.

OLD diskettes used under NEW TRSDOS without XFERSYSing, may
cause extraneous information to be read at the end of
files, giving a false End-of-File (EOF) indication. Some
programs will not function properly under these conditions.
NEW diskettes used under OLD TRSDOS, may not access all
data and/or NEW programs may not run correctly.
see the TRSDOS
section of your TRS-80 Model III Disk System Owner's
Manual
If you need to use the XFERSYS utility,

Note: When changing from one TRSDOS to the other, you MUST
press the RESET button each time the diskette in
is changed. You may also XFERSYS onto a NEW
Drive
disk.
If this is done, all system files of the
data
system diskette will be moved onto the data diskette.

RADIO SHACK APPLICATION PROGRAMS WHICH WERE DELIVERED ON AN
OLD TRSDOS DISKETTE SHOULD NOT BE XFERSYSed.
TRSDOS 1.1 and 1.2.
TRSDOS 1.3
A collection of information stored as one
named unit in the directory,
program:
A file which causes the computer to
perform a function,
data:
Information contained in a file which is
used by a program,
system diskette: A diskette containing TRSDOS. When this
diskette is placed in Drive
and the
RESET button is pressed, TRSDOS will begin

OLD:
NEW;
file:

to run.

data diskette:

XFERSYS:

A diskette which does not contain TRSDOS.
If this diskette is placed in Drive
and
RESET is pressed, the screen will clear
and "Not a SYSTEM Disk" will be displayed.
A program contained on the TRSDOS 1.3
diskette.

8759117-681

Tips C n Load og Disk basic
There are several ways, other than those described
basic

program

-F.files -m:

is a trsdos
program. This

file
is

specification for a Disk basic program. After start-up, Disk basic will run the

optional.

F.files fells Disk basic the

number from

maximum number

So 15. This is optional;

needed, you must include the
-w.address

all

options are omitted, Disk basic

The options allow you
•

•

•

A program

omitted, 3

to run after

will

any or

to specify

Disk basic

is

is

used.

If

at

one time, diesis

Variable length

suffix v after files; otherwise, files will

memory above the
memory up to Top.

all

may be open

of files that

if

Disk basic not to use

omitted, Disk basic uses
If

the manual, to start up Disk basic.

address

program

tells

in

of

be Fixed length.

specified address. This

is

optional;

if

MANY FILES? and memory?

prompt with HOW
all

a

files are

the following:

started.

of data files that may be Open at one time. The larger the number of files,
the less area available for storing and executing your programs. (Note: Each Fixed length file takes
up 360 bytes and each Variable length file takes up 616 bytes of memory.)

The maximum number

The highest address to be used by Disk basic during program execution. Omit
going to call machine-language subroutines.

Under trsdos ready,

if

unless you are

you type:

BAS I C (ENTER) Disk
memory prompts.
,

this

basic

will

enter the

command mode once you answer

the

files

and

BASIC - F 1 fEMTEff Disk basic will Open one fixed length file and protect no memory.
BASIC -M: 32000 (ENTER) Disk basic will Open three fixed length files and will use
memory no higher than 32000.
BASIC PAYROLL - F 3 (ENTER Disk basic will start-up. then load and run the basic
s

,

,

:

>'

).

program called payroll; three variable length
available memory.
Note:

If

will still

files

can be Opened, and basic can use

all

you PATCH Disk basic to prompt you for cassette speed when you enter Disk basic, you
be prompted with CASS? no matter which option you use.

Important Note for Model

III

ERROR 31

1.3 version of trsdos will return with
attempt to use the ROUTE command.

The

trsdos

(PROGRAM NOT FOUND) when you

Thank-You!

I

A

Division of

Tandy Corporation

8759109

1.3 Users!

_^_ _

rpie-eQ
U

r,.
:

"

®

i

Dfek

Omfner e
s

ipytofiuia!

^r A DIVISION OF TANDY CORPORATION
FORT WORTH, TEXAS 76102
;

r

TRS-80 Mode! Ill Disk System Owner's Manual: © 1980 Tandy Corporation, Fort Worth,
Texas 76102 U.S.A. All Rights Reserved.

III BASIC Software: © 1980 Tandy Corporation and Microsoft. All Rights Reserved.

Model

The system software

in the

Model

retained in a read-only

III

microcom-

memory (ROM)

Reproduction or use, without express written permission from Tandy Corporation or any portion of
this manual is prohibited. While reasonable
efforts have been taken in the preparation of this
manual to assure its accuracy, Tandy Corporation
assumes no liability resulting from any errors or
omissions in this manual or from the use of the

puter

information obtained herein.

of this material without the prior written authorization by Tandy Corporation is strictly prohibited.

Model

III

TRSDOS®

is

format. All portions of this system software,
format or other source code
whether in the
circuitry are copyform format, and the
righted and are the proprietary and trade secret
information of Tandy Corporation and Microsoft.
Use, reproductions, or publication of any portion

ROM

ROM

Operating System:

© 1980 Tandy Corporation, Fort Worth, Texas
76102 U.S.A. All Rights Reserved.

10

987654321

n

O WNER'S MAMUAL

-.,

.

.

Congratulations on your purchase of the Model III Disk System. We think it's a
valuable tool which will save you work as well as give you hours of enjoyment
(or maybe both at once). You'll have all the power of the non-disk
Model II!,
plus the following features:

Your Computer can now be controlled by trsdos®, the powerful trs-so Disk
Operating System, trsdos is included on a diskette with the Disk System.
Using trsdos, you can run a wide variety of programs, such as the Disk basic

•

•

interpreter included on the trsdos diskette.

Each "system" diskette has approximately 126,720 bytes of storage available
your own programs and data; each "data" diskette has 178,944 bytes

•

for

available.
•

You can load and save data

the approximate rate of

250,000 bits per second.
Your system can continue to grow in power and convenience. When Radio
Shack issues improvements and enhancements to the system programs, you
can "install" them simply by obtaining a new release of the trsdos diskette.

•

at

Publications related to the use of the
1.

Model

Model III Disk System Owner' s Manual
Manual" for short.

III

(this

Disk System:
manual). We'll

2.

Model

3.

Model 111 Operation and basic Language Reference Manual,
Manual" for short.

4.

Model HI basic Quick Reference Card.

III

call

it

the

"Disk

Disk System Quick Reference Card.
the

"Model

III

For Disk Operation:
This Disk Manual supplements the Model III Manual. Use the Disk Manual as
the primary source of information; we'll tell you when to refer to the non-disk

Model

III

Manual.

For Non-Disk Operation:
To use the Computer
Manual.

as a non-disk system, all

you need

is

the

Model

III

For Programming Information:

The Model
that

III

Manual contains most of

which pertains

the

programming information, except
manual, we will assume that you

to disk input/output. In this

TRS-80

are familiar with the

Model

III

MODEL

ill

DISK SYSTEM

basic programming definitions and details given

in the

Manual.

III Disk System is intended for use by novices as well as
experienced computer operators and programmers. In designing and writing
Disk Manual, we've tried to define and satisfy the needs of both groups:

The Model

Novices

•

who might

prefer a sequential presentation

this

which emphasizes

procedures and explains the purpose of various features.
•

Experienced users who might prefer a more analytical presentation which
makes it easy to find specific information.

manual, you'll find information
group you might belong to.
In this

The "Sample Sessions"

that should satisfy

your needs, whichever

are especially geared for novices, while the Technical
more experienced users.

Information chapters are for the

mind, however, that it isn't necessary to read the entire manual to
operate the Disk System. If you are only interested in Disk basic, for example,
read the Operation section of this book and then turn directly to the Disk basic
section. You can then go back to the trsdos section when you need to.

Keep

in

Special

Terms

non-technical sections of this manual, we've had to use numerous
special terms. Rather than scattering and repeating definitions throughout the
book, we have used the following convention which we hope you'll find

Even

in the

helpful.

Special terms which are fully defined in another part of the manual are printed in
boldface. Look up the word or phrase in the Index; this will tell you where the

word

is

fully defined.

mSBBBBBB^E

0-

*

'

V-'J,saa

'

R'S MAN!

Contents
Operation
Installation

............:„.,„..,.....„...„

1

Operation ...................,,......,.....,,,...,,....,,,..,,. 4
Diskettes .......................................................

5

n Description fj Care
System Start-Up

6

Important Disk Operations

backup

format

8

Q Model

1 /

III

Conversion

Disk basic

1

Quick instructions

Start-Up

Loading

Baud Rate

Troubleshooting and Maintenance

13

Notation and Abbreviations ....................................... 14
Specifications

1

TRSDOS
Description of trsdos

Roles

17

basic

ram Use

Q Memory Map

Using trsdos

20

Commands

20

n Entering
File Specification
File

Forms

Syntax

.............................................. 22

Name .................................................

.

.

,

23

Drive Specification

23

Password

24

A Few

24

Important Definitions

Commands ............................................. 26
Commands
67

Library
Utility

Technical Information

Disk Organization

74
File Structure

trsdos Error Codes/Messages

Systems Routines (I/O)

90

TRS-80

MODEL

Disk

ill

DISK SYSTEM

BASIC
91

Introduction

Enhancements

to

Model

Q] Abbreviations fj

III

93

Disk basic

Commands
116

Disk-Related Features
File

Methods of

Manipulation
File

File

Access

Access

Q] Sequential

145

Q Random

Disk basic Error Codes/Messages

155

Index

157

Customer Information

160

Warranty ...........................

iv

..........

Back Cover

•v

*V*mmt

*•%»*»,-»•

if"!

"ERATH ON

mmm

up the Computer according

First set

to the instructions in the

If

you have a one- or two-drive system,

in

drives should be ready for use.

If

you have

Model

Manual.

III

installation

is

now

you need

to

connect the external

a three- or four-drive system,

LJli

complete. The built-

drives.

External Disk iirives
The two

external drives are not interchangeable.

Shack Catalog Numbers and a few

First External

They have

different

Radio

internal differences.

Drive Purchased

System

Catalog

Name

Number

'Drive 2/3'

26-1164

(Includes Cable)

Second External Drive Purchased

The 26-1 164 drive may be used

'Drive

as Drive 2 or 3, depending on the

drives in the system. In a three-drive system,
drive). In a four-drive system,

The 26-1
Drive
1

161 drive

may

2"

it is

it

is

number of

always Drive 2 (the

always Drive 3 (again, the

only be used

26-1161

in a four-drive

system, in which

Locate the

flat

"ribbon" cable

that

was included with

must be

the 26-1 164 drive.

has a single plug on one end, and two plugs clustered
other end. See Figure 1 for plug labels.

3.

it

2.

Notice that

2.

last

last drive).

it

at the

Connect the solitary "Computer" plug to the Disk Expansion Jack on the
bottom rear of the Computer. See Figure 2.

Now

refer to

Figure

3.

Connect the external

drive(s) to the other

end of the

cable, as follows:

3-A.

3-B.

4.

If you have one external drive (26-1 164):
Connect it to the "Drive 2" plug near the middle of

1

the ribbon cable.

If you have two external drives (26-1 164 and 26-1 161):
Connect the 26-1 164 to the "Drive 3" plug on the end of the cable.
Connect the 26-1 161 to the "Drive 2" plug near the middle of the cable.

m
mm
If

Plug the external drive(s) into an appropriate source of AC power. Power
requirements are specified on the unit and in the specifications given in this

PH

f

manual.

You

are

now

1
ready to

start the

Disk System.
IIP
i

iH

§£3

\m

r
I

.

.

'SB

IODEL

ill

DISK SYSTEM

JMW^

Computer Plug
Drive 3 Plug

Figure

1.

External Disk Cable with Plugs Labeled.

Figure

2.

Connection

2

of the External Disk

Cable

to the

Model

Attach the plug so the cable exits
toward the rear of the Computer.

EDGE CARD PLUGS

Figure

3.

Connection

GUIDE

PIN

of external disk drives.

GUIDE SLOT

IiliiilK

KM

WSSSM

Operation
few minutes to become familiar with the various elements of your
Disk System. Refer to Figures 4 and 5. This is very important. If you try to use
the Computer without having a little background information, you could damage
First, take a

a diskette.

Figure

4.

The Model

© Drive 0. The trsdos
in this

©

III

Disk System with External Drives (optional/extra).

"system diskette" goes

©

Drives

1, 2,

Reset Button.

and

3.

These

drives

may

contain "data diskettes." Data diskettes are
described briefly in this chapter.

©

Drive Select led. When a drive
accessed, its led lights up.

©

Drive Door. To insert or remove a diskette,
open this door. Never remove a diskette
while the led is lit, or while the diskette
cohtains open files.

is

being

©

When

you press this button,
attempt to load the
operating system software from Drive 0. The
trsdos diskette should be in Drive when
you press this button.
the

drive.

Computer

will

Power Switch. All drives should be empty
when you turn the Computer on or off.
Otherwise, the information on the diskettes
could be destroyed.

mniB&m

* sp

yPtHAISOl'

©

©.

©

Figure

5.

A

Diskette. (Catalog

© Storage
use,

Envelope. While a diskette
keep it here.

© Write

Protect Notch.

When

this is

is

Number 26-305, 26-405,
not

in

covered,

the disk-drives cannot write (change information) on the diskette. Do not pinch the tab
into

the notch when you apply it. If the tab
indented, the disk drive may not

©

or 26-406)

Read/Write Window. The disk drive
accesses the diskette surface through this
window. Don't touch the diskette surface.

© Label. To write on
tipped pen.

might

this label,

Any other

damage

writing

use only a feltimplement

the diskette.

becomes

sense that the disk is write-protected. Leave
the notch uncovered if you want to save or
change information on the diskette.

© Jacket. The

diskette

is

permanently sealed

inside this protective jacket.
to

remove

Do

not attempt

it.

Diskettes
In general, handle diskettes carefully, using the

same precautions you use with

tape cassettes and high-fidelity records. A small indentation, dust particle, or
permanently.
scratch can render all or part of a diskette unreadable
'

Keep

the diskette in

its

storage envelope whenever

it

is

not in one of the

drives.

not place a diskette in the drive while you are turning the system on or off.

•

Do

•

Keep

diskettes

away from magnetic

fields (transformers,

ac motors, magnets,

tvs, radios, etc.). Strong magnetic fields will erase data stored on a diskette.

¥wlrl£

a^4FIND = 00 >CHG = FF

i

like to

change

this,

use

(ENTER)

Consequently, you will be prompted with: CASS? whenever you

start

Disk

basic.

You may then type

either H (High) or L

(Low)

to

choose the

rate

you need.

To change the system diskette back to its original state (i.e., no CASS?), simply
use the trsdos patch command again but reverse the find and chg values.

12

OPERATION

j

Troubleshooting and Maintenance
If you have problems operating your Model III Disk System, please check the
following symptoms and cures, and check the corresponding table in your

Model
If

III

Manual.

you can't solve the problem, take the unit to your local Radio Shack. We'll
it fixed and returned to you as soon as possible.

have

Symptom

Cure
Check

Disk drive motors run
continuously
is

when

the

Computer

turned on.

external drive connection sequence.

Drive 26-1

1

64 must always be the

last

external drive.

Computer will not load trsdos.

1

2.

Make sure you have inserted the
trsdos diskette properly in Drive 0.
Make

sure

all

peripherals are properly

connected.
Error

Messages

Look up the message

in

the

trsdos

or

basic Error Message Section. The "cure"
should be listed.
Frequent disk

i/o

errors

1

2.

is

diskette,

then re-format

Diskette

is

partially

it.

out. Use backup copy,
make a new working copy.

worn

available, to
3.

erased. Backup the

Diskette

if

Disk drives need cleaning or alignment

by Radio Shack service technicians.

Maintenance
For reliable operation, the disk drives must be kept clean and properly aligned.
These procedures should be done by Radio Shack service technicians, according
to the

following schedule:

Degree of Use

Maintenance Interval

Commercial data processing

Every month for medium use.

environment
Occasional

home

use

Every 8-10 months; more often

if

needed.

For further instructions, see the Troubleshooting and Maintenance section
your Model III Manual.

in

13

For the sake of clarity and brevity, we've used some special notation and type
styles in this book.

capitals and punctuation
indicate material

which must be entered exactly

as

it

appears. (The only

punctuation symbols not entered are ellipses, explained below.) For example,
in the line:

DUMP
every

letter

lowercase

LISTER (START = 7000, END

= 7100JRA = 7004)

and character should be typed

as indicated.

italics

represent words, letters, characters or values you supply from a set of acceptable

values for a particular

command. For example,

the line:

LIST filename
indicates that

you can supply any

valid

file

Ellipsis indicates that the preceding items

ATTRIB filename

(option,

indicates that several options

.

.

specification after list.

can be repeated. For example:

.)

may be

repeated inside the parentheses.

This special symbol is used occasionally to indicate a blank-space character
(ASCII code 32 decimal, 20 hexadecimal).

PRINT "HHHIH!"

X '««««'
Indicates that

of this

book

nnnn

is

a

hexadecimal number. All other numbers

in the text

are in decimal form, unless otherwise noted.

X'7000'
indicates the hexadecimal value 7000 (decimal 28672).

COMPUTER TYPE

Any words, letters, or numbers that are displayed on the screen will be in
computer type (dot-matrix). Uppercase letters are used; however, your screen
times

14

may

display lowercase letters instead.

at

OPERATION

J

Specifications
Diskettes

5

A"

l

mini-diskettes

Radio Shack Catalog

Number 26-305,
26-405 (package of three),
or 26-406 (package of 10)
Diskette Organization

(Formatted Diskette)

Single-sided

Double-density

40 Tracks
18 Sectors/Track

256 Bytes/Sector
Operating Temperature

55

to

80 Degrees Fahrenheit

13 to 27 Degrees Celsius

Power Requirements
(External Drives)

120 VAC, 60 Hz, 28 VA (240 VAC, 50
Hz, Australian; 220 VAC, 50 Hz,
European)

15

^tnn

>
5=3=3

"WiliilS

Sifts

E=2S

ISDQS
i

m

Description of TRSDOS

What Is TRSDOS?
trsdos (pronounced "triss-doss") stands
It fulfills

System."

Master Program

1

2.

Command

3.

Program Manager

As

Interpreter

the master

components
•

for "trs-80 Disk Operating

three roles:

program, trsdos enables the microprocessor and

The components

to interact efficiently.

Random Access Memory

its

various

include:

(ram), trsdos reserves space for

its

own

needs and

allocates space for user programs.
6

Disk Drives, trsdos interfaces with the disk hardware and provides a
system for storing system and user data on diskettes.

e

Input/output devices. These include the keyboard, video display, printer, and

file

rs-232-c equipment.

trsdos is also a command interpreter. Whenever it displays TRSDOS READY,
you may enter commands that control how the system works. These are known
as "library"
In

its

role as

commands.
program manager, trsdos

will load

and run system or user

programs. During this time, the system or user program

control of the

is in

Computer.
Figure 7

illustrates the relationships

here Does
Referring to Figure
package" category.

BASIC
7,

between these three

roles.

Fit ta?

you'll see that Disk basic falls under the

Disk basic consists of some general enhancements
disk input/output capability.
possible. For instance, the

It

uses

Model

Model

III

basic

III

to

Model

basic (stored

rom

includes

all

III

in

"language

basic, plus the

rom) whenever

of the mathematical

functions.

you're used to the non-disk system, there's one difference you should
understand from the beginning: In the non-disk system, basic is in control
If

you

start-up. In the disk system,

up.

You have

to tell

trsdos

running a program written

to

when

however, trsdos is in control when you startload and run basic. Only then can you begin

in basic.

17

1§

T RS-8C

L_..J"

\

iiSii

trsdos

is

ram

SYSTEM

stored on the system diskette included with your Disk System.

time the Computer
into

ISK
MMlMiiMiMi

so

it

is

turned on or reset, the trsdos master program

is

Each

loaded

can take charge.

trsdos occupies approximately 40,000 bytes of space on the
only a portion of that

is in

ram

at

once. This

is

diskette;

possible because

however,

trsdos

is

divided into several independent "modules."

The "resident" module
drivers, tables, the

is in

memory

command

at all times. It consists

of input/output

interpreter, and other essential routines.

Additional modules are loaded as needed, and replaced (or "overlaid") by other

modules when they are no longer needed.
Note: After you enter a library or utility command, you will usually hear
trsdos accessing the system disk. It is loading an overlay module which
contains the code necessary to complete the command.

The Memory Map

memory

18

space.

in

Figure 8

illustrates

how trsdos

utilizes the available

laster

Program

Command

Program Manager

Interpreter

System Utility
Programs (FORMAT,

Language packages

Z-80

(Disk BASIC,

User

BACKUP,

Editor/Assembler,

Programs

etc.)

etc.)

Figure

7.

trsdos Roles.

»fe3#4-

4000H

*°" z

5200H
5500H

Zil

W

.

T

,

.

.

*

Do

WmBf
MBsBBm

,

*

Y.

You can combine the two

with the

files

command:

APPEND PAYROLL/B PAYROLL/A
payroll/a

will

now

look like

this:

PAYROLL/A
Atkins
W.R,
Baker* J.B.
*

Chaiiibe rs

D

o d s o

n

>

Ki ck anion

li

W

.

»

T

.

Lewis* G E
Miller* L
Peterson* B.
Rodriguez* F
,

Note:

Do

.

.

,

...
Y

.

.

payroll/b
(ASCII).

.

.

C.P.

>

.

.

.

,

,

,

...
.

.

.

will be unaffected.

To see

APPENDed

the

file,

LIST

type

JOLL/A

Pf

not load a program under basic after an append.

Change a Fie

9

s

Password

=m

attrib ills (visibilityMC
•

ff/e is

the

visibility

file

?£,upu=

level)

specification.

must be

i

or n. Tells trsdos whether the

Non-invisible (n) (see dir).

Acc=Mmete!is trsdos
is

ns.pwi =

:

utisiranyed.

If

If

\k& access word.

acc

=

,

is

If

Invisible

file is

omitted, visibility
minified

is

is

set to
*

blanks.

upd

-

= name tells trsdos
is

unchanged.

If

the update word.

upd =

,

is

used,

tits

If

or

word

the access

used, the access word

(i)

unchanged.

-

omitted, the update word

update word

is

set to

blanks.

27

fiC

i

'':'

*mmm

prot =

fei/e/ tells

/eve/

is

trsdos the protection level

for access.

If

omitted,

unchanged.
acces s granted by access

Level

Degree

full

Full access,

kill

of

wo rd

no protection.

Kill,

rename, read, execute, and write (gives

total

access,

i.e.,

the least-protected).

name

Rename,

write

Read, execute, and write.

read

Read and execute.

exec

Execute only.

read, execute, and write.

Note: Each level allows access to itself plus

all

lower levels.

you change the passwords to an existing file or makes the file
Passwords are initially assigned when the file is
created. At that time, the update and access words are set to the same value
(either the password you specified or a blank password).
attrib

lets

invisible or non-invisible.

ATTRIB DATAFILE

Makes

the

password

(

»ACC = JULY14 »UPD=M0USE PR0T=READ
*

invisible, sets the access password to julyw and the update
mouse. Use of the access word will allow only reading and

file

to

executing the

file.

ATTRIB PAYROLL/BAS .SECRET (N»ACC=»)
Sets the access

word

level assigned to the

The
update word is
to blanks.

file is

left

made

non-invisible and the protection

unchanged.

ATTRIB OLD/DAT, APPLES :;,i:s|«M«

BUILD
Commai

Create an Automatic

file is a -file

command

specification which cannot include an extension.

you create an automatic command input file which can be
executed via the do command. The file must contain data that would normally
be typed in from the keyboard to the trsdos ready mode.
This

build

files

been typed

lets

are intended for passing
in at the

trsdos ready

command
level.

lines to

trsdos

just as if they'd

Note: clear cannot be used in a

do

file.

When you

enter the build

prompts you
(JEN TIB).

to

command, build

creates the

file

and immediately

begin inserting lines. Each time you complete a

(While typing in a

line,

you can use

line, press

the usual cursor control keys for

erasures and corrections.)

To end the build
First type:

You

file,

simply press (BREAK)

at the

beginning of a

line.

BUILD filename

will then

command text. You then type in up
You may enter as many lines as necessary.

be prompted to type in the

63 characters, then press ENTER)
(

.

Press (BREAK) to quit and return to

to

trsdos ready.

A Sample BUILD-Fiie
Here's a hypothetical BUiLD-file that initializes the serial interface and the printer
driver:

BETCOM 3,ESW

= aaa3 tells
is

If

= bbbb teils
is

&#M»,MEM =

fffffffi)

TRSDOS where to

trsoos

to clear

user

a four-digit hexadecimal

used, start

= ««

se»&

start clearing

hexadecimal number from

rse

= aaaa must
memory

sfi-e

ill

i

memory

memory

number

assist than iho

to a specified

all a

end. bbbb

101,1

memory.

ol

this option is

If

is

to vrr?.

ccce
If

is

a

'

>ur-digit

this option is omitted,

reset to end of user ram.

faiiable

ram

ir

;leai bo\

me r.j;*'-

memory, the Display is cleared,
drivers are reset (see Memory Requirements of rRSoos).
protect

This

command

gets

is

reset to end of

you off

memory

Zero user

•

Clear the Display

•

Un-protect

See

all

all

i

o

to a fresh start.

Depending on the options you
9

user

of

no less than the start

protect address

protect address

options are omitted

If

end

this option is

also be used.

hexadecimal number from nuuu
the

user memory, aaaa

6Qoo to the

this option is omitted. 6000 is used.

numbei and

mem

•

a four-digit

memory.

end

-

select, this

command

(load binary zero into each

will:

memory

address above 6000)

memory

Memory Requirements

protect address. Note:

of trsdos for more information on
clear cannot be used in a do file.

the

memory-

Example
CLEAR (START=9000tEND=0A000)
Note: Hexadecimal numbers which begin with a
(see above example).

CLEAR (MEM=7000)

32

letter

must be prefaced by zero

I

TRSDC

up

-

CLOCK
Turn

Oo Clock

Display

clock {switch)
svi/iich
If

gives trsdos one of two options, on or off.

option

is

omitted, trsdos uses on.

command controls the real-time clock display in the upper right corner of
Video Display. When it is on, the 24-hour time will be displayed and
updated once each second, regardless of what program is executing.

This
the

Clock display

is

off

at

trsdos

start-up.

Note: Except during cassette and disk

i/o,

regardless of whether the clock display

is

the real-time clock

is

always running,

on.

Examples
CLOCK
Turns on the clock display.

CLOCK

(OFF)

Turns the clock display

off.

See time and date.

CLS
Clear the Screen

CLS

This

command

clears the Display

and puts

it

in the

64 character/line mode.

Example
CLS

33

"RS-80

--^M WBH3)

; Ejr^'.in

MODEL

111

DISK SYST!

v:«B«t»

Illjljjjjii:,

Copy a File or

Files

Three forms:
copy source-file destination-file

A)

source-file

is

a

file

specification for the

file to

destination-file is a file specification for the

duplicate

source-file

is

name and

drive of the

file.

copy source-file :d

B)

be copied.

'

defined above.

:d tells trsdos to

copy the

file

onto drive

d,

using the

same

file

name.

copy I exf.d

C)

eat

is

a 'wild-card'* file specificz-tiOR in which the fife

name

is

omitted and the extension is given, trsdos will copy all files
which have a matching extension, regardless of the file name.
.

-

-J

defined above.

Is

command copies source-file into the new file defined by destination-file.
This allows you to copy a file from one disk to another, using a single drive if
necessary. (In the latter case, you must include drive specifications in both file
specifications.) For single-drive systems (Drive 0), both diskettes must contain
This

trsdos.

(i.e.,

Data diskettes aren't allowed

in

Drive 0.)

Examples
COPY OLDFILE/BAS NEWFILE/BAS
Copies oldfile/bas into a new file named newfile/bas. trsdos will search
through all drives for oldfile/bas, and will copy it onto the first disk which
not write-protected.

COPY NAMEFILE/TXT
This

command

specifies a

COPY FILE/EXTS0
This

34

command

si
file

named namefile/txt

to another disk.

si

copies file/ext from Drive

to

Drive

1

is

________^^
COPY /BAS:0
tells

trsdos

will be

to

TRSDO S

c

:1

copy

Drive

all

copied onto Drive

1

,

which have the extension /bas. The files
file names and extensions.

files

using their present

Sample Use
Whenever

a

file is

disk

is

make

updated, use copy to

can also use copy to restructure a

file

a

backup

for faster access.

file

Be

on another disk. You

sure the destination

already less segmented than the source disk; otherwise the

new

be more segmented than the old one. (See free for information on

file

could

file

segmentation.)

To rename

a file

create

on the same disk, use rename, not copy.

fibnsme

filename
lhl

= ma

{lrl

=

saa.Rtc

She file specification.

is

is

the logical record length, aaa

between zero and
rec

= 6M

is

the

command

lets

which space

is

written into the
If

you open the

is

different

allocated to a

is

omitted. 256

is

allow

number

a decimal

assumed.

'or.

bbh

is

sBirmv n

the

omitted, no resriMJi are allocated

file

and pre-allocate

(set aside)

space for

its

from the default (normal) trsdos procedure
dynamically,

i.e., as

necessary

when

data

in

is

file.

file

for sequential writes,

unused granules when the

trsdos

file

if

of records to

l*

you create a

future contents. This

255.

number

records des red

This

=&

file is

trsdos will de-allocate (recover) any
you open the file for random access,

closed. If

will not de-allocate space

when

the

file is

closed.

35

,

;

-;^*/!

TRS-80

MODEL
——
r~™

III

-

;

DISK—--;

You may want to use create to prepare a file which will contain a known
amount of data. This will usually speed up file write operations. File reading
will also be faster, since pre-allocated files are less segmented or dispersed on
requiring less motion of the read/write mechanism to locate the
the disk

—

records

Examples
CREATE DATAFILE/BAS (REC=300> LRL=0)
Creates a

file

named datafile/bas, and

allocates space for

300 256-byte

records

CREATE NAMES/TXT. IRIS
Creates a
large

file

enough

(

LRL = G4 »REC = 50

named names/txt
to contain

protected by the password
50 records, each 64 bytes long.

iris.

The

file

will be

CREATE PAYROLL/BAS
Creates a

file

named payroll/bas

but allocates no space to

it.

Sample Use
Suppose you are going to store personnel information on no more than 250
employees, and each data record will look like this:

Name (Up

to

25

Social Security

letters)

Number

(

1 1

characters)

Job Description (Up to 92 characters)

Then your records would need
You could

create an appropriate

CREATE PERSONNL/TXT
Once

to

(

with

1 1

+ 92=

this

128 bytes long.

command:

would allow faster writing than would
trsdos would not have to stop writing
more space (unless you exceed the pre-allocated

file,

periodically to allocate

file

+

REC=250 >LRL= 12B

created, this pre-allocated

dynamically allocated

be 25

file

since

amount).

DATE
Reset or Get Today's Date

bate

mm/dd/yy

mm

dd yy

is

the specification for the

month {mm), day

{dd)

year {yy).

a»a»
36

and

a

TRSDOS

Each must be a two-digit decimal number between the following
ranges:

mm

01-12

dd

00-31

yy

00-99

The specifications are an option; however,
used, they

all

if

one specification

If

mrn/dd/yy

is

omitted, trsdos displays the current date.

II

mm/dd

&

glvei

This

command

You

initially set the

lets

yy

you

is

must be used.

,

iksdos resets the Dale

reset the date or display the date.

date

when trsdos

the date automatically, using

its

is

started up. After that,

built-in calendar.

You can

trsdos updates

enter any two-digit

year after 1900.

When you

request the date,

trsdos displays

it

in the format:

07/Z5/80

for July

25, 1980.

Examples
DATE
Displays the current date.

DATE 07/18/80
Resets the date to July 18, 1980.

DEBUG
Start

Debug Monitor

DEBUG

command starts the debug monitor, which allows you
debug machine-language programs.

This

to enter, test,

and

37

m

tip
Is
s

..

JIS

MODEL

TRS-80

III

DISK

SYSTB

ISSS»

Its

features include:

memory

contents

•

Full- or half-screen displays of

'

Commands

•

Single-step execution of programs

a

Breakpoint interruption of program execution

•

Transfer of control (Jump)

•

"Editing" of disk-files

for modifications to

ram and

register contents

debug uses the memory area from X'4E00' to
Map), debug can only be used on programs

X'54FF* (see

trsdos Memory

in the user area X'550cr to top.

Examples
DEBUG
Turns

debug on. Press

®

to quit

debugging and return

to

trsdos.

Q

Turns

debug

off.

Command Description
are usually entered by pressing a single key. In most cases,
you do not have to press (ENTER) after the command has been typed in. Either
a prompt will immediately be displayed or debug will execute the operation

Debug commands

without further instruction.
In

some

(see r

cases,

and

address

is

you

have

will

commands,
typed in, you
J

Once you have entered
special commands:

to enter a specific

hexadecimal value or address

for instance). Instead of pressing (ENTER) after the
will

the

have

to press CS PACEBA R).

debug program, you may use any

of the following

D (Display Memory Contents)
Press

©

to display the contents of

prompt: D

memory

ADDRESS

location

The display

will

=

you wish

in the

will

respond with the

hexadecimal address of the

to see.

be either half- or full-screen, depending on the format you are

currently using (see below).

38

memory, trsdos

You should type

TRSDOS I

tamsaMMMHraannt osssst

--. :-

,;

X (Half-Screen Display)

®

Press

memory

Display in the half-screen format. A 128-byte block of
be displayed starting with the next lowest address which is a factor

to put the
will

of 16.

Figure 9 shows a typical half-screen format.

S (Full-Screen Display)
Press

©

to display the contents of a

next lowest address which

is

256-byte block of

memory

starting with the

a factor of 256.

Note: The last 16 bytes on the Display will be overlaid by any
typed in after the full-screen display is updated.

command

line

M (Modify RAM)
change to the disk utility display format (see the f command).
respond with the prompt: M ADDRESS = You should type in the
four-digit hexadecimal address of the memory location you wish to modify,
followed by a blank space (anything other than a space will abort the
Press

(HD to

trsdos

will

command).
The display

will

change

to the

memory

edit format.

The cursor

will

appear as a

blinking character at the specified location.

To

exit the

modify mode, press ENTER)
(

to

keep

changes made.

all

R (Change Register Contents)
Type:

*

n as, 6M>ft (spacebar:

aa

is

bbbb

1Mb

name

of

one

of the register pairs af, bc, de, hc, or pc.

the four-digit hexadecimal value which will be loaded into aa.
U fewer than four digits are typed In before pressing (spacebar)

is

.

leading zeros are sssumect.

I

(Instruction Single-Step)

Pressing CD will allow the Computer to execute a single z-80 instruction.
display will then be updated.

The

»Ml«gi«i«lTOpf

39

'si-

•.

-i

TR

MODEL

-80

ill

Start address
of one 16-byte
"row" of

RAM

DISK SYSTI

RAM display-

ASCII display

hex contents
of each byte

nondisplayable

(•

indicates a

character)

mm

m

Z-80 register contents
at the "PC" address

Op-code Instructions

Figure

The

Half-Screen Format.

9.

instruction in the

memory

contents referenced by the program counter

executed.

The program counter

control

returned to debug.

debug

C
If

is

will not,

is

is

increased by the appropriate value, and the

however, step through a

call or

jump

into a

rom

address.

(Call Single-Step)
you wish

to

Otherwise,

You

is

returned to

this instruction acts just like

will not

©. The call is
debug when the subroutine returns.
the command.

complete an entire call/return sequence, press

then executed and control

be able to step through a

I

call or

jump

into a

rom

address.

U (Update)
Pressing

from

40

this

(U)

causes the Display to be updated repeatedly. Press any key to exit

mode.

IfiiPii^sififflfilfii

T RSDOS

f

mm
;

(Increment Display Address)

If the

Display

is

half-screen, the

first

location

you press CD- If the full-screen format
incremented by 256.

—

is

shown

is

incremented by 16 when

displayed, the starting address will be

(Decrement Display Address)

If the

Display

press

Q.

is

half-screen, the

If the full-screen

first

format

is

location

decremented by 16 when you

is

displayed, the starting address will be

decremented by 256.

J (Jump)
Press GD to transfer control to a machine-language program, setting optional

breakpoints.

Debug

will

respond with the prompt: J ADDRESS?

=

You may type in a jump address and a breakpoint address. The command
terminated when you press (ENTER) Type in the addresses in one of three

is

.

formats:

j

address?

j

address?

jaddbess?

aaaa

=
=
=
is

aaaa, bbbb Center)

aaaa

CI11I1)

.bhbb

mtm

a four-digit hexadecimal address specifying the

destination-

bbbb

is

if

omitted, the address

in

jump

the pc register

is

used.

a four-digit hexadecimal address specifying a breakpoint.

Before the Computer executes an instruction at this address,
will retura control to debug.

If

this

address

h

it

omitted, control

will no! return to debug.

beginning of z-80 instructions. You may
The breakpointed address will contain an
encountered. Then the original contents will be

Notes: Breakpoints must be set
not set breakpoints in

ROM

XT7' until the breakpoint
restored and

debug

is

at the

addresses.

will take control again.

Q (Quit)
Pressing (D turns off

debug and

returns control to trsdos.

41

—
1.-T-

(

F

p

(File

This

.>

Patch

command

When you
name of

^^ ^_^ ^E^

_

^^ ^^

SHE

|P%

|

g*%

Hrf"

gj^&

\/' ^& "jjF If™

jl

g

Utility)

lets

you load and modify

press 2D,

the

^^^

^_^

file to

debug

will

the contents of a diskette

file.

respond with the prompt: FILESPEC?. Enter the

be patched.

debug will set up a full-screen display showing the first 256
You can "page" through the file using the CD and ED keys.

bytes in the

file.

Figure 10 gives a typical display.
In this file-display

mode, both hexadecimal and

a code has no displayable character, a period

The display control commands

CD

Next page

CD

Previous page

is

ascii are given for each byte. If

shown

are like those for the

in the ascii area.

normal file-display mode:

To change the file contents, press (M). This puts you in a modify-memory mode
like the one previously described. Use the arrow keys to position the cursor (a
blinking character), then type in the correct contents as a hexadecimal value.
When you are through changing a page on the display, press (ENTER) The
diskette file will be updated and you will be returned to the file-display mode.
.

To cancel changes made, do not press [ENTER) press [B REAK) This will put you
back in the file-display mode without updating the diskette file. You may press
CD then CD to restore the page display to its actual contents.
,

.

To quit patching a file, press (BREAK) while in the file display mode, debug will
prompt you for a new file specification. Press (BREAK) again and you will be
returned to trsdos ready.

42

TRSDC
WMBEM61MHBXNNS8&1

Drive

#

Record #

Byte Offset
within Record

Hexadecimal Contents of
Each Byte
,

ASCII Translation

f/m

mmm

HBP

I

Sip*

m

Figure 10. Full-Screen Format

43

MODEL

-80

Bii

DISK SYSTEI

List the Diskette Directory

DIR :d(lNV,SYS,PRT)

:dl$ the desired drive directory.
inv lists the invisible

user

If

files,

if

omitted, Drive

is

assumed.

omitted, non-invisible user files are

listed.

sys

lists

system and user

files,

if

omitted, only non-invisible user files are

listed.

prt

lists

the directory to the Printer.

1"

omitted, in* directory will be listed

on the Video Display only.

no option

If

This

command

To pause the
listing,

is

given, trsdos

lists

non invisible user

gives you information about a disk and the

(

Drive 0.

files

contains.

it

To continue, press ENTER) To terminate

listing, press (W).

press BREAK)

files in

(

.

the

.

Examples
DIR
Displays the directory of non-invisible user

DIR

:1

files in

Drive 0.

(PRT)

Lists the directory

of the user

files in

Drive

1

to the Printer.

Sample Directory Listing
(See Figure 11.)

Definition of

column headings

©

— The name and extension assigned

File

Name

The password

©

Attributes

The

first

(if

any)

character

is

44

either
is

to a file

when

not shown.

— A four-character

The second character

The

is

s

i

field.

(Invisible) or

(System) or

third character gives the

n (Non-invisible).

* (User) file.

password protection

status:

it

was

created.

ligiJiiiifc

TRSDOS
s^^^^w^

WSBBBBDtiBBBfflB&&®HBffl

l
©

©

®

/

\

ililiii|lllipll|i

©

/

/

./

/

/

WBB Jllllllli «WS iff
^MillllifS?|f

illlUBt

Illl

Figure

11. Directory Listing.

x The

file is

a The

file

u The

file

has an update word but no access word.

The

file

has both update and access words.

B

The

unprotected (no password).

has an access word but no update word,

fourth character specifies the level of access assigned to the access word:
Total access

and everything

1

Kill file

2

Rename

3

This designation

file

and everything
is

©
©

5

Read and everything

6

Execute only.

7

No

Number

below.

listed

below.

not used.

4 Write and everything

®
©

listed

listed
listed

below.
below.

access.

of Free Granules

Logical Record Length

— How many

free granules

— Assigned when

the

file

was

remain on the diskette.
created.

— How many
have been
Number of Granules — How many granules have been used
Number

of Records

particular

logical records

written.
in that

file.

MmmemMMWMfflBBmm
45

Jfe TRS-80 MODEL

]

..

©

.

Number

111

DISK SYSTE

— How many segments (contiguous blocks of up

of Extents

granules) of disk space are allocated to the

©
®

End of

File (eof)

Creation Date

— Shows

— When

Begin Aeto

the

the last byte
file

was

to

32

file.

number of

the

file.

created.

Command Input from a BUILD-FIle

do command-line

command-line

is

the

be specified.

This

command

name

ii";£

of file created with build.

file will

No extension should

automatically be given

tine

extension Bin,

reads and executes the lines stored in a special-format

created with the build

command. The System executes

the

file

commands just

as

if

they had been typed in from the Keyboard.

Command

lines in a

build

file

may

include library

commands

or

file

specifications for user programs.

When do
to

reaches the end of the automatic

command

input

file, it

returns control

TRSDOS.

The debug and clear command cannot be included
In addition to executing

user programs

name be

from a

in a

build

file.

trsdos library commands, you can load and execute
You will probably want to make your program

DO-file.

the last line in the DO-file.

Examples
DO STARTER

trsdos

will begin automatic

command

input from starter, after the operator

answers the Date and Time prompts.

AUTO DO STARTER

Whenever you
from starter.

46

start

trsdos,

it

will begin automatic

command

input

TRSDOSiL

Sample Uses
Suppose you want
on

to set

up the following trsdos functions automatically

start-up:

FORMS (WIDTH =80)
CLOCK

(ON)

Then use build to create such a file. If you called it begin, then use the
command: AUTO DO BEGIN to perform the commands each time TRSDOS
starts up.

Duplicate Output to Video and Printer

dual {switch)
switch

This

command

is

one

two options, on or

of

duplicates

all

video output

off.

II

omitted, trsdos uses on.

to the Printer,

and vice versa.

It

takes

effect immediately.

Notes:
1

Video and printer output may be different because of
between output devices and output software.

command

down

intrinsic differences

2.

Using the dual

3.

The dual command cannot be used during route and vice

4.

The

printer should

will slow

the video output process.

versa.

be ready when you execute the command.

Sample Use
For a printed copy of

all

system/operator dialog, type: DUAL (EMTER )

To turn off the dual process, type: DUAL

(

OFF

)

(

ENTER )

47

TRS-80 RflODEL

\$Z~

f-l-

DISK SYSTEM

lii

DUMP
Store a

dump

Program

file

= aaaa, end = bbbbjm =

(start
the

fffe is

start

=

sasa

tra = cccc
is

is

the start address cf

memory

the end address of the

is

tfcteW)

aaaa must be a

black,

memory

block,

bbbb must be

is

the transfer address

where execution

starts

when

a four-

the program

loaded, cccc must be a four-digit hexadecimal number.
is

= dddd is
into

four-

to x'7000.'

hexadecimal number.

option

relo

=

hexadecimal number greater than or equal

= bbbb
digit

ccccrelo

specification

file

digit

end

Into a Disk File

omitted, the

will default to

this

trsdos re-entry.

the start address for relocating or loading the program back

memory.

option

command

If

is

cfcWtf

must be a

four-digit

hexadecimal number.

If

this

omitted, no relocation will take place.

must be hexadecimal form, without the x'
notation.
You must add the prefix "0" to any hex number which begins with a

Mote: Addresses

'

letter.

This

command

copies a machine-language program from memory into a
You can then load and execute the program at any time by entering
name in the trsdos ready mode.

program
the

file

file.

Examples
DUMP LISTER

(

START = 7000 >END=7100 ,TRA=7004

Creates a program

file

named lister/cmd

-

locations x 7000" to x'7ioo\

When

containing the program

in

same
The program

executable for

trsdos will protect memory beginning
the trsdos ready mode.

DUMP PR0G2

(START=7000»END=7F00»TRA=8010(RELO=8000>

addresses, and

Creates a program

x

-

7000- to x'7foo'.

Execution will

48

file

named prog2/cmd

When

memory

loaded, lister/cmd will occupy the
at x'70oo\

containing the program in addresses

loaded, prog2/cmd will reside from x'sooo' to

start at x'soio*.

x'SFucr.

is

TRSDOS

rii
'

sue

_

.

ERROR
Display Error Message

error number

number is

This

command

a decimal

number

trsdos error code.

for a

displays a descriptive error message. For example, after

* ERROR 47 * * you may respond with the
47
(ENTER
and trsdos will display the full error message.
ERROR
command:

receiving the message, *

)

For a complete list of error codes and messages, see the Technical Information
section of this manual.

FORMS
Set Printer Parameters

FORMS (WIDTH

=

W, LINES

width = wis the

=

I)

maximum number

reaches this length, trsdos
Sine.

lines

If

this option is omitted, the current

used. To disable the

maximum

trsdos

new

= / is

will not force

the

number

However, basic
displacement
is

This

The

command

of characters per output line.

use

it

in

new

width will be

use width = 255.

trsdos does not use this value.

computing the necessary page

for execution or

you modify the

a line

lines.

omitted, the current value

lets

maximum

line width feature,

of Sines per page,

will

If

will insert a carriage return to force a

if

is

lprint ckrs(12j

is

executed.

If

lines

=/

used.

printer forms control features of trsdos.

default values are:

Maximum

line width:

132

Lines/page: 60

forms

also sets the line count to 0.

49

.

JtJ.3

TF1S-80

MODEL

DISK SYSTEM

111

mum

Examples
you are using 8'/2"-wide forms, you
FORMS (WIDTH=80)

If

probably want to

will

If

you are using 14"-long forms, you may want

to set lines

set

width =

80:

= 78.

(LINES=7B)

FORMS

This change will allow the basic statement, lprintchr$02), to advance a page

by the correct number of

lines.

Notes:
1.

The width you specify
specify

2.

The

is

stored in

ram

is

ram

stored in

location 16427.

must be ready when you execute

Printer

The lines you

location 16424.
this

command.

FREE
Display Disk Allocation

Map

FREE :tf(PRT)
:tf is

the drive specification.

(prt) tells
it

This

command

1280 bytes,

is

directory and

When

trsoos

to

1!

omitted, Drive

send the map

map

often

to the

Video Display

only.

of granule allocation on a diskette. (A granule,
It

also

shows

the location of the

sectors.

a diskette has been used extensively

etc.), files

map

the unit of space allocation.)

any flawed

used.

to the Printer.

emitted, trsdos sends the

gives you a

is

become segmented

(file

updates,

files killed,

extended,

(dispersed or fragmented). This slows the

access time, since the disk read/write

mechanism must move back and

across the diskette to read and write to a

forth

file.

free helps you determine just how segmented your disk files are. If you decide
you'd like to re-organize a particular file to allow faster access, you can then
copy it onto a relatively "clean" diskette.

50

TRSDI
dBttmSKR

Examples
FREE

map

Displays a free space

of the diskette in Drive 0.

FREE (PRT)
Lists the free space for

FREE

to the Printer.

(PRT)

si

Lists the

Drive

Drive

1

map

to the Printer.

A Typical FREE Display
Four special symbols are used

in the

free map.

Unused Granule

A

Direct

Directory Information

X

Allocated Granule

Flawed

Granule Contains a Flawed Sector (Unusable)

typical free

map

display

is

shown

in

Figure

Disk

12.

Name

All six

granules

in

track 2 are allocated

/

,

^ ^ v£ ,^
.

.

Wk

m

wm
m
Hi

t

mmm*

m

Figure 12. Free Map.
The directory
on track 17.

1

is

located

HFT P
Explanation of TRSDOS
help

Command

command
command is
help.

the specific trsdos

If

omitted or

if

command

or subject on which wou

an invalid subject

is

given, trsdos will

need

list all

available subjects.

i

51

t
;qn]

\wP!fflPi$if

If

YSTEM

i;v^

I

you type

WBBMSB/SBBBS&MBHttMBSBMM
'

BACKUP (ENTER) trsdos will respond with
command, and an explanation of

following: HEELP

in the

the syntax format, a definition of the
the abbreviation.

HELP SYNTAX

trsdos

tells

to explain the

help descriptions.

KILL
Delete a File or

Group

of Files

Two syntaxes:
A) kill

file

file is

B) kill

/ex/
:d

This

command

used.

Form A

is

each

If

specification

is

a file extension that

a drive specification.

deletes one

file

from

file

all files

must contain three characters.
It

musihs

provided.

files, depending on which form
no drive specification is given,

or a group of

deletes the specified

deletes

file.

file

iextd

trsdos deletes the

Form B

a

the

file.

If

diskette that contains

first

it.

with a specified extension, regardless of the

no drive specification

drive that contains a matching

file

given, the

is

files will

file

name of

be deleted from the

specification.

Examples
KILL TESTPROG/BAS
Deletes the

named

file

from

the

KILL JOBF LE/ I DY, PASSWORD
Deletes the

named

file

drive that contains

first

:

from Drive

.

The

file

has a password of password.

KILL /BAS:0
Deletes from Drive

52

all files

it.

1

1

having the extension /bas.

is

first

;

-

LIB

Commands

Display Library

LIB

This

command

the Display

lists to

all

the library

commands. For help with

a

command, use help.

Example
LIB

LIST
List Contents of a File

LIST fi7e(PRT,SL0W,ASCII)

the

file is

file

specification.

prt tells trsdos to

list

to the Printer.

If

omitted, only the Video Display

is

used.

slow

tells

trsdos

to

pause

briefly after

each record.

If

omitted, the listing

is

continuous.
ascii tells

trsdos

format

This routine

lists

is

to list the file in ascii format.

If

omitted, hexadecimal

used.

the contents of a

file.

The

listing

shows both

the

hexadecimal

contents and the ascii characters corresponding to each value. For values
outside the range (X'20\ X'7F'), a period

Use

is

displayed.

the ascii option for text files and basic

programs saved with the a option.

Note: Only ascii codes xw-x'7F' are sent to the Printer. Bit 7

is

always

set to 0.

During the

listing, press

(@D to pause, (ENTER)

to continue, or

(

BREA K) to exit.

53

Examples
LIST DATA/TXT

(ASCII

data/txt

Lists the contents of

LIST FILE/A

)

(SLOW)

Lists the contents of file/a,

LIST PROGRAM/CMD
Lists the file

format.

in ascii

pausing after each record.

(PRT)

program/cmd

to the Printer.

LOAD
Load a Program

load

file
file is

This

command

file is

File

a file specification for a

file

created by

loads a machine-language program

loaded, trsdos returns to the trsdos

You cannot use

this

command

to load a

basic. See the basic Reference

Manual

trie

file

dump command.

into

memory. After

the

ready mode.

basic program or any
for instructions

file

created by

on loading basic

programs.
Note: The

file

must load

into the user area (X'7000'-top).

Examples
LOAD PAYROLL /

PT

Sample Use
Often several program modules must be loaded into

memory

for use

by a master

program. For example, suppose payroll/pti and payroll/pt2 are modules, and

menu

is

the master program.

Then you could use

the

commands:

LOAD PAYROLL/PTI
LOAD PAYROLL/ PT2
to get

54

modules

into

memory, and then

type:

MENU

to load

and execute menu.

MASTER
Set Master Mead/1

MASTER (DRIVE

a

is

W

'

Drive

k

= a)

the drive specification.

If

omitted Drive

is

set as the master drive.

command

allows you to assign a specified drive as the Master Read or
Write drive in the system. When searching for a file, trsdos will start with the
master drive.
This

If the file is

the next

not found on the specified drive, trsdos will continue searching on

higher-numbered drive.

Example
After you enter the

command: MASTER (DRIUE =

1

)

Drive

1

becomes

the

master drive.

PATCH
Change the Contents

patch

file

(add

file is

add

a Disk Fie

= aaaa,nm = bh,zm = cc)

the

file

= aaa&
digit

find

off

specification

specifies the address at which the data

is

found, aaaa

is

a four-

hexadecimal number.

= bb specifies

the string you wish io find (or

compare

to),

bb

is

a

hexadecimal sequence.
chg

=

cc specifies the

new

coirtsnls foi the. byte(s). ce is a

hexadecimal

sequence.
Note: This

utility is for

machine language programs

only.

55

TRQ-ft(

B&2 "a

1
.

nummi

This

command

You know

1

you make minor corrections

lets

You can use patch

to

string of

to

file,

to

your

provided

you want

code or data with another

make minor changes

programs; you won't have
create the

any disk

the existing contents and location of the data

You want to replace one
same length.

2.

in

to

that:

change.

string of the

own machine-language

change the source code, re-assemble

it,

and

re-

file.

Another application for patch is to allow you to implement any modifications
trsdos that may be supplied by Radio Shack. That way, you do not have to

to

wait for a later release of the operating system.

Sample Use
Suppose you want
First
is

change seven bytes

to

in a

machine-language program

determine where the seven-byte sequence resides

loaded.

Then make

sure your replacement string

is

of the original string. For example, you might write

in

the

ram when

the

same length

down

file.

program

as that

the information

as follows:

File to

be changed:

vread

Start address: X'5280'

Sequence of code

to

Replacement code:

Then you could use
PATCH VREAD

pause

(

-

X'00000009'

the following

command:

ADD=5280 »FIND=0CD2D25E5 >CHG=00000009

message
message
is

56

be changed: xcd2D25E5

is

the

message

optional.

If

to

be displayed during the pause execution. This

omitted, pause will he displayed by

itself.

JRSDOSJ^jg|:
*
'D=R)
tape-to-RAM transfer, trsdos will prompt you for the cassette baud
and will tell you to press (EMTER) when the recorder is ready to play to the
Computer. After loading the program, trsdos will begin execution at the
transfer address specified on the tape.
Starts a

time

rate,

hh:mm:ss
hh:mm:ss specifies the hour

hh,

mwutj mm,

mi

second

ss.

Each must be a two-digit decimal number between tie following ranges:

64

hh

0-23

mm

0-59

ss

i-59

If

hh:mm:ss

is

giwen, trsdos resets the time.

If

hh:mm:ss

is

not giwen, trsdos displays fte current time.

TRSDOS
warn

command

This

lets

you

Time uses a 24-hour
You

initially set the

reset or display the time.

clock. For example, 1:00 P.M.

time

when trsdos

the time automatically, using

When you

its

is

is

displayed as 13:00.

started up. After that,

trsdos updates

built-in clock.

request the time, trsdos displays

it

in this format:

14:15:31

for

2:15:31 P.M.

Examples
TIME
Displays the current time.

TIME 13:20:00
Resets the time to 1:20:00 P.M.

Note:

If the

clock

is

allowed to run past 23:59:59,

it

will re-cycle to zero, the

date will be incremented, and the clock will continue to run.

Write-Protect Via Software

wp

(drive =d)

d specifies the

disk drive to be protected.

If

omitted,

all

drives will be

unprotested.

Diskettes can be protected from being overwritten by this

command. It is a
software write-protect rather than a hardware write-protect (such as the writeprotect tab

on the

diskette).

Only one drive may be protected
To unprotect a drive, making

wp

it

at a time.

accessible to writing, simply enter the

without options or with a different drive

number

specified.

command

The wp command

will not override a write-protect tab.

65

ODEL

DISK SYSTEM

111

Examples
WP

(DRIME=1)

trsdos

will write-pro tect the disk in

Drive

1

WP

trsdos

66

will eliminate write-protection

on

all

drives.

TRSD Q

BACKUP
Create an Exact Copy of an Original Disk

backup -.source -.destination

source specifies the drive containing the original diskette.
trsdos

will

prompt you

If

omitted.

for this information.

-.destination specifies the drive containing the diskette to receive the copy,
.

omitted, trsdos will prompt for

•.source

backup copies

if

It.

en& destination may reference

line

same

drive.

the contents of the source disk to the destination disk. This gives

you a "safe" copy of the disk. Always keep an extra copy of data or programs
you have stored on your disks.
Note: Both source and destination diskettes must be write-enabled.

trsdos
If

prompt you

will

at

each step after you type: BACKUP

you omitted the source/ destination-drive numbers, trsdos
SOURCE DRIVE NUMBER.

will begin with the

prompts:

Type

in the

OTTER)

number of

the drive that contains the source diskette and press

.

DESTINATION DRIVE NUMBER?
Type

in the

number of

press (ENTER)

the drive that will contain the destination diskette and

.

SOURCE DISK MASTER PASSWORD?
Type

in the

password assigned

to

your source diskette.

DISK CONTAINS DATA* USE DISK OR NOT?
Type

in Y

(Yes) or N (No).

DO YOU WISH TO RE-FORMAT THE DISK?

Type

in Y

(Yes) or N (No).

67

\

jSE trs-80_model

,

ail

you specified the source/destination drives, trsdos
password, skipping the first two steps.
If

will then take charge of formatting

trsdos

well as letting

you know

if

will request the

and verifying the destination disk as

there are any errors or flawed tracks.

CON VERT
Model

I to

Model

III File

Conversion

Utility

CONVERT

Model

I

formatted diskettes cannot be used in the Model

Disk System.

III

However, the convert utility can read a Model I diskette and copy its nonsystem files onto a Model III trsdos diskette. This diskette may then be used
normally in the Model III Disk System. The original Model I diskette may still
be used in a Model I Disk System, since it is unchanged by convert.

convert does not convert or change data; it converts the file storage format.
For this reason, Model I Disk basic programs may require slight changes before
they will run properly in the Model III Disk System. Model I machine-language
programs may require major or minor changes before they will run in the Model
III Disk System. You may make these changes on the Model I diskette before
using convert, or on the Model III diskette containing the converted files.
For hints on program conversion,

see:

manual

•

Technical Information

8

Technical Information in the

•

The manual, Instructions for Converting Specified Model
on trs-80 Model 111.

in this

Model

III

Manual
I

Programs for use

Drive Usage
In two-drive systems, the files
in

Drive

must be copied onto a Model

0; in three- or four-drive

diskette in Drive

1

,

systems, the

files

may be

III

system diskette

copied onto a data

2 or 3

During the conversion process, the Model I diskette is referred to as the
"source"; the Model III diskette, the "destination." The source diskette cannot
be in the same drive as that of the destination diskette.

68

Password Protection
convert

is

transfers.

To accomplish

designed to preserve the password security of each file that it
this and still allow the copying of protected files,
convert follows different procedures depending on the access and update
passwords on each file.

and update passwords. The copied
be given blank passwords. (If you have a Model I Disk System with
trsdos 2.3, you may use the prot command to remove all passwords from all
files. This will simplify the convert process. Do this on the Model I system
In the simplest case, a file has blank access
file

will

before you attempt to convert to

Model

III.)

In another case, the access and passwords are different. If the access password
is blank and the update is not, then trsdos will prompt you for the update

password. If you know the update password, type it in. The file will be copied
with access and update passwords set to the old update password. If you don't
know the update password, simply press ENTER) The file will be copied with the
(

.

access password set to blanks and the update password set to an
If the

unknown

value.

access and update passwords are not blank and they are not the same,
will not copy the file, but will print the message, FILE SKIPPED, and

trsdos

continue with the next

file

in the source directory.

Sample Use
Get the Model

you have a Model I Disk System with trsdos
passwords from all your files. This will prevent any
problems with passwords. The password protection may be restored with the
Model III attrib or prot commands after the conversion is complete.
2.3, try to

I

diskette ready. If

remove

Using the Model
diskette in Drive

The program

all

III

0.

Disk System, you must always have a Model III trsdos
trsdos ready should be displayed. Type: CONCERT CENTER)

.

SOURCE DRIVE?. Type in the number of the drive
Model I diskette, and press (ENTER) Then the program will ask,
DEST I NAT I ON DR I VE? Type in the drive number and press CENTER) In twodrive systems, you must use Drive
as the destination.
will ask,

containing the

.

.

.

During the conversion process, the name of each file will be displayed as it is
copied. If password information is needed, trsdos will prompt you for it. If
you know the update password, type it in and press (ENTER) The file will be
copied and given the same update password. If you do not know the update
password, simply press (ENTER) in which case the file will be copied and given
an unknown update password.
.

,

name on

is already used on the destination diskette,
FILE EXISTS, USE IT?. If you type Y,
will copy the file. The previous contents of the Model III file will be
lost. If you type N, trsdos will skip the file, and get the next one from the
Model I diskette.

If

a

file

trsdos
trsdos

the source diskette

will print this message:

69

FORMAT

FORMAT

:rf

f/

Si-icjifies
f?

This

command

fe? disk d^vc which contains the diskette to te f!rro&*?ei.

omitted, tbsdos will prompt you for

you prepare data

lets

diskettes (either

undesired data or programs), leaving a

program and data

may

BACKUP

Or FORMAT.

format

takes a blank

When format

it,

new

maximum amount

only be used in Drives

1

,

2,

or disks which contain

and 3 except during a

(new or magnetically erased) diskette, records track/sector
then initializes it with and creates a directory.

detects a non-blank diskette,

it

will display a

and press (ENTER) if you do want to reformat,
you want to save the disk information.

Y (Yes)

( ENTER

)

if

format

warning message:

will lock out

any defective tracks

to prevent data

N

(No) and press

from being

lost in

these areas.
If

you begin

to get

read

errors during access, reformat the disk.

Example
FORMAT

si

After you are prompted for DISKETTE NAME? and MASTER PASSWORD)
TRSDOS will format Drive 1

70

d

of space for your

DISK CONTAINS DATA* USE DISK OR NOT?
Type

If

wwrjWierL

files.

Note: Data diskettes

boundaries on

Ms

TRSDOf:

:-

m

Up for 50 Hz AC power (non-USA users)

Set

DO HERZ50
starts the utility to

change the system

for

50 Hz operation, herzso

is

a do-

file.

This

utility is

than 60 Hz.

provided for customers

in areas

where

the

ac power

is

50 rather

should not be used by any other customers, herzso simply places
a patch on the diskette that changes the clock speed for 50 Hz users.

herzso
file.

a DO-file that

is

Drive

It

diskette

Once

is

makes

a

change

changed. Be sure

the herzso change

is

in the

it is

done,

it

software of trsdos. Only the

write-enabled before you

will

remain

start the

do-

in effect for that diskette.

To perform the change, type:
DO HER250

Once

the

change has been made, you will need to

change into

effect.

This loads the

new

reset the

system

to put the

software into ram.

lpc

The lpc utility program allows trsdos to ignore multiple carriage return
commands. Without lpc, a top-of-form (LPRiNTCHR$(i2» command will add an
extra carriage return/line feed each time it is executed. Also, lpc masks the high
bit of each data byte, allowing you to send certain intercepted codes to the
printer.

128=

For instance, the basic statement lprint chr$( 140)

will

send code 140-

12 (lprintchr$(12» to the Printer.

71

;•-

'in
f^g TRS-80 MODEL

The

printers that require

Line Printer

lpc

111

DISK SYSTEI

are:

(26-1156)

III

Line Printer VI (26-1166)

Daisy Wheel WP50 (26-1157)
Qume Daisy Wheel (26-1 157A)
Daisy Wheel II (26-1158)
and

future printers.

all

Printers that

do not require lpc:

26-1150, 1152, 1153, 1154, 1159, and the a version of

lpiii

(26-1 156A).

the lpc program before you load an application program. The
way to do this is to copy lpc onto your data/program diskette and then
the auto command to load lpc automatically each time you use the system.

You must load
easiest

use

For instance, type:

COPY LPC:
Then,

to

i

:0

(

ENTER)

make lpc an auto command on

AUTO LPC/CMD

the diskette, type:

(ENTER)

Whenever you use your program diskette, lpc will automatically
memory and you can use the program as usual.

load into

is no need to set MEMORY
"hides" itself. However, you still need to set memory if
required by your application program, lpc will be killed if the clear command

lpc locates into the highest available memory. There

SIZE
is

to protect lpc.

It

used.

Warning: Once

the lpc utility

program

is

loaded and installed, you should not

except after a reset. Reloading re-installs the program and uses up more
space each time! lpc will not execute if the Printer has been routed elsewhere.
Also, if lpc has been executed and then the Printer is routed elsewhere, the
original printer driver will regain control after the routing.
reload

it

MEMTEST
Test

Memory

MEMTEST

This program tests your Model Ill's memory (read only and random access). In
trsdos ready, just type MEMTEST and press (ENTER)
.

72

ISDO

The program automatically tests all memory locations, no matter what memory
size you have. First it checks read only memory (rom); if everything is okay, it
automatically goes on and checks random access memory (ram). If all ram
checks out okay, the program continues.
If the program detects a rom or ram error, it will display a detailed message.
Repeat the test to make sure it is a valid error condition. Write the message
down and contact your nearest Radio Shack for assistance.

Note: memtest changes the entire contents of ram. Before running
you have saved any valuable code you may have in ram.

it,

be sure

XFERSYS
Transfer System Files

XFERSYS

xfersys lets you upgrade your version of Model III trsdos by copying all
system files from a new release diskette (source) onto a previously released
diskette (destination) (i.e., version

1

.

2 to version

1

.

3

,

etc

.

)

System files which already exist on the destination diskette are replaced by those
from the source diskette. Files which do not exist on the destination diskette are
added. User files (program and data) are unaffected.

Steps to upgrade a diskette

Make backup copies of all diskettes to be upgraded. This is an important
precautionary step. These backup copies should be kept until the upgrading
process is complete and confirmed.
Note: Both source and destination diskettes must be write-enabled.
Insert the

type

new

XFERSYS

release of
CENTEH)

trsdos

into Drive

and press the reset button. Then

.

After the program heading appears, trsdos will prompt you with DISKETTE
CONVE RT READY IN DRIVE 1
Y / )?. Type Y (yes) or
(quit) and press

TO

(

(ENTER)

.

The upgrading process will then take place. When the process
trsdos will tell you so and take you back to trsdos ready.
Note:

If

is

complete,

an error occurs, including your trying to upgrade a non-system diskette,
be cancelled and take you back to trsdos ready.

the operation will

73

-:

T^S-80

-'•""

MODEL

1!I

DIS K SYST1

Contents of This Section:

Disk Organization
File Structure

System Routines for Assembly i/o
Data/Device Control Blocks
Physical and Logical Records
Fundamental trsdos i/o Calls
Additional Routines and Storage Addresses
trsdos Error Codes/Messages

Disk Organization
Each trsdos system diskette contains a trsdos system, a
library, and a file directory.
Each

diskette

utility

command

40 tracks of information. Each track
256 bytes each.

single-sided and has

is

contains 18 sectors of

Normally, data read/ write operations

may be

initiated only at sector boundaries,

and must consist of exactly 256 bytes. However, trsdos allows the user to have
maximum flexibility with minimal effort by automatically blocking and deblocking
requires

accesses to user-specified logical record lengths, even

all file

"spanning" of two

The system disk

file

if this

sectors.

structure allows

maximum

use of disk

file

space by

automatically segmenting files across a diskette in several small pieces.

These

file by the system without
your needing to know the physical file location. This structure eliminates timeconsuming disk-packing operations.

pieces are correlated into one logically contiguous

A

^

File Structure

A trsdos

*i

composed of one or more segments of storage space. Each
segment consists of from one to 32 physically contiguous granules of storage.
granule

is

file is

the

minimum

£,

A

allocatable unit of storage, and consists of three sectors

(768 bytes).
Since a file is always lengthened by granules, a small amount of free storage
generally present at the end of every file. This free storage allows minor file
additions to be

made

in space

which

is

physically contiguous to the

file.

Every time a disk file is extended (either initialized or lengthened), extra
granules may be allocated to that file, depending on the file's accumulated
length, diskette space, saturation, etc. These extra granules, along with all

74

is

^

^f

^

v

^
Ji

^p

Jr

v,

v4?

TRSDOS KSfeS^Mt

granules after the one containing the
system when the file is closed.

file's

eof mark, are recovered and returned

to the

A TRSDOS ile

GRANULE

SEGMENT:

GRANULE

1

EOF
2

GRANULE 32

2

SECTOR X +

SECTOR X +
BYTE

BYTE1

SECTOR:

LRN:

EXTENT

SECTOR X

GRANULE:

LRNN

LRN3

LRN2
EXTENT 1

LRN1
FILE:

|

BYTE 256

BYTES

2

2

Logical Record Number, used to specify an individual, user-defined
logical record. Such a logical record is the smallest unit of
information which can be addressed during disk input/output (a
physical record

is

the unit

which

is

actually read

from or written

to

disk).

A group of logical records; the largest unit of information which can
be addressed by a trsdos command.

File:

Sector:

A

physical record,

composed of 256 contiguous

Granule: The minimum allocatable unit of storage for any
Extent:

One

bytes.
file.

contiguous allocation of granules.

System Routines for Assembly-Language I/O
is provided for customers who wish to write their own
assembly level i/o routines. An explanation of the calling sequence and
parameters for each necessary i/o routine is given. A knowledge of z-80 machine
code is assumed.

This information

The following notations
(HL)

=

xxxx

are standard in this section:

Registers

hl contain

the address of (point to) xxxx in

format. (If address of xxxx
registers are:

= 34B2H

h = 34; l = B2). Other

machine

then the values in the
register pairs will also

be

indicated this way.

a = xx

Register a contains the numeric value of xx in binary form.

used to return the trsdos error code for i/o calls.
A complete list of error codes and their meanings appears at
the end of this chapter. Other registers will also be indicated
Register

this

a

is

way.

75

-'•<

" ---' 'SM
1

Bay

-.;.

FRS-80

I

m
Z = OK

Zero

MODEL

DISK SYSTEM

IBS

from the system

flag is set (OK) if successful return

routines.

402D

X nnnn
or nnnnn

Hard ram address

lrl

Logical Record Length, 1-255 bytes only. You can define
records any length you wish up to 255 bytes maximum. A
length of zero is a special case for physical records only, and

in

hex notation

256 user-designated bytes
from or write sectors into.

in

ram

If

lrl = o,

lrl

this area if

alter this area

is

when using

for

trsdos

X'402D').

to read sectors

this area is the

manage before and

responsibility of the user to

manages

is

lrl = 256 bytes.

indicates the

BUFFER

(e.g.,

between

after i/o.

and 255 bytes.

1

Do

trsdos
not

logical record processing.

UREC

(User Record) The address of the contiguous ram byte-string
assigned by the user as his logical record area. Its length must
be equal to lrl. It is a different area from buffer.

lsb/msb

Least-significant byte followed

by most

significant byte. This

is

the standard z-80 format for addresses.

The "$"

$name

is

prefixed to

all

system locations and

they will not be confused with trsdos

call routines, so

commands

or

utilities.

For example, sopen.

DCB before $OPEN and after $CLOSE
The dcb (device control block) is defined
designated by the user. Before $open and
compressed (no spaces) ascii
is

as

50 contiguous bytes of ram

after

$close,

string, as in a standard

is

trsdos

filespec.

The

string

24

16

8

I

1

i

e

1

n

a

m

e

/

e

X

P

t

a

s

s

w

Notes:

/ext,

.password, and

$ stands

for

r

:d

a carriage

are optional.
return (X'OD')

I

I

d

$

d
i

i
1

76

a left-justified,

terminated with a carriage return.

1

f

it

I

I

r

m
'

''mm

:

::rSm>(''Sim''eiiX.

DCB while $OPEN
Address

Length

DCB + O

Explanation

Reserved

3
2

+3

Physical Buffer address (lsb/msb)

+5

Offset to delimiter at end of current record

+6
+7
+8
+9
+ 10
+ 12
+ 14

NRN

File drive

number residence

Reserved
eof offset

of last delimiter in last physical record
lrl (logical record length)
nrn (next record #
$open sets = xwoo'
lsb/msb)
ern (ending record #
(last in file) lsb/msb)

2
2
50

Reserved

Next Record Number defines which record

next system call for $read or $write.
after

each system

direct

trsdos

ERN
is

—

—

call.

It is

random

In order to process

you wish

to the record

Ending Record Number

is

is

to

be read or written by the

automatically incremented by one
files,

use the $posn call to

to transfer next.

the last record

put into the directory at SCLOSE time, so

if

it is

number

currently in the

file. It

expected to be correct, the user
This value may also be used to

must close his files after adding records to a file.
position to end of file so that new records may be added to the end of the file. To
position to the end of file use a call to sposn with a record number of ern + i.
$posn is described later.

Physical

and Logical Records

in

TRSDOS

A physical record

is defined as one sector of disk. One sector of disk contains
256 user data bytes. The artificial term "granule" is defined to be 3 sectors of
disk space. There are 6 granules on each of the 40 tracks on the disk. A granule
is the least amount of space allocated by trsdos. For programming purposes,
the physical records in a file are numbered from
to N. The largest record
number (N) in a file will then be 3 times the number of granules allocated minus
one ((3*G) - 1). All trsdos granule allocations are made as needed at the time

of write, not when the file

Bytes

is

Granules

Sectors

256
768
4608
184320

created.

3

Tracks

Disk

—

1

18

6

1

720

240

40

Disk Space Table: For each 5 A" Disk Drive
l

A

logical record is defined

255 bytes

in length.

by the user of tRsdos. It may be anywhere from 1 to
file is opened with a specific lrl (Logical Record

Once a

77

Length), the length

must close

it

is

fixed until the

and re-OPEN

Each opening of the
on the

with the

it

new

To change a

file's

lrl, you

lrl.

from) one physical record for

maximum

space utilization

disk.

Blocking

is

putting

more than one

logical record into one physical record. For

instance, four 64-byte logical records will

A

closed.

a single, fixed record-length, trsdos will "block"

file sets

logical records into (or

file is

logical record

may be broken

into

two

fit

one 256-byte physical record.
by trsdos in order to fill the last

into

parts

portion of one physical record entirely before beginning to use the next physical

record

(i.e.

records are spanned). This occurs

when

the physical record length

is

not an even multiple of the logical record length.
If the

user wishes to do his

own blocking,

he

may

specify a logical record length

must himself manage the contents of the
of
physical record buffer area of 256 bytes, trsdos will not move a logical record
for the user if lrl = 0; in this particular case it will only read/write the physical
record to/from the buffer. Once control is shifted to your program, you will have
about 20 bytes of stack size left.
bytes at the time of init/open and

Fundamental

TRSDOS I/O Calls

There are 17 fundamental trsdos routines involved

in

handling

file i/o.

These

are:

$BACKSPACE

$FILPTR

$POSN
$PUTEXT
$RAMDIR
$READ
$REWIND

$INIT

$SYNTAX

SKILL

$VERF
$WRITE

$CLOSE
$DIVIDE

$DMULT

$OPEN
$POSEOF
The

detailed calling sequences and discussions for each of these routines follow.

Note that

all

of these system calls use register f and do not restore

its

value

before return. In order to apply this data properly, you should read through
these descriptions and clear

up

all

all

of

of the points that are not obvious to you by

using other reference materials. If you are successful in doing this you will find
that

trsdos

$INIT

is

a workable tool for your programming ideas.

— 17440/X'4420'

an entry point to trsdos which will create a new file entry
and open the dcb for this file. $init scans the directory for the
name given in the dcb. If the filespec name is found, $init simply opens

$init is provided as
in the directory

filespec

78

TRSD21

the file for use. If the

name

is

not found, a

new

file is

created with the filespec

name.

Entry Conditions
(HL)
(DE)

= buffer
= DCB

(see beginning of this section for notation)

= LRL
CALL $INIT
B

Exit Conditions
iy

z

= changed
= OK

c carry flag is on if a new file was created
a = trsdos error code. (Error codes listed

$OPEN

— 17444/X 4424
?

at

end of

this chapter)

?

$open provides a way to open the dcb of a file which already exists in the
directory. The dcb must contain the filespec of the file to be opened before entry
to

$OPEN.

Entry Conditions
(HL)
(DE)

= BUFFER
= DCB

=

LRL
CALL $OPEN
B

Exit Conditions

= OK
if file does not exist.
z =
a = trsdos error code.
iy = changed
Z

$POSN— 17474/X

?

4442'

randomly selected logical record. Since
is done to locate which
physical record(s) contain the data. Following a $posn with a $read or $write
will transfer the record to/from ram.
$posn positions a
it

file

to read or write a

deals with logical records, the proper computation

79

[ISK

Note

that positioning to logical record zero sets the file to read the first logical

record in the

file.

To position

to

end of

number ern +

end, use the record

file

in order to

add new records onto the

1

Entry Conditions

= dcb (must have been opened previously)
bc = Logical record number to position for.
CALL SPOSN
(DE)

Exit Conditions
Z

a

= OK
= trsdos

error code

$READ— 17462/X'4436

?

lrlo, $read transfers the logical record

whose number is in the dcb as nrn
urec for the length lrl as defined at open time.
The record comes from "buffer" defined at open time. If trsdos must read a
new physical record to satisfy the request, it will do so. "Spanned" logical
records will be re-assembled as necessary. $read automatically increments nrn
by 1 in the dcb after the transfer is completed. $init/open set nrn^x'oooo' in
If

into the

ram

area addressed as

order to read the
If

first

record with the

first

read.

lrl = o, $read transfers one physical record into buffer, defined at open
from the disk file. Registers hl are ignored. $read increments nrn as

time,

above.

(HL)
(DE)

= urec
= dcb

if

lrl

is

not zero.

Unused

if

lrl = o.

CALL SREAD

Exit Conditions
Z

a

= OK
= trsdos

= x*ic or
eof or nrf)

error code. (eof

(see errors 28,29 for

x'id*)

$WRITE^ 17465/X 4439'
?

If

lrlo, swrite transfers the one logical record from the

urec for the length lrl
buffer which was defined
as

80

at

ram

area addressed

open time. The record goes into the
open time. If trsdos must write a physical record

as defined at

it will do so. "Spanning" will be handled by
$open time the dcb value of nrn is set to X'oooo'
so that the first record will be written. After each logical record is transferred,
the nrn value in the dcb will be incremented by 1

in order to satisfy the request,

trsdos

If

as necessary.

lrl = o, $write

At

$init

transfers

one physical record from buffer

into the disk file

nrn in the dcb. buffer is defined at $init/open time
nrn is updated as above, after the write.

using the

value

only.

The dcb

Entry Conditions
(HL) = urec
de = dcb
call $wr1te

if

lrl

is

not zero. Unused

if

lrl = o

Exit Conditions
Z

= OK

a = trsdos

error code.

-17468/X'443C
The only difference between $verf and swrite

is that $verf writes one physical
back into a special trsdos ram area not defined
This special area and the original write buffer are then compared

record to disk and then reads

by the user.
byte by byte

it

to assure that the record

was successfully

written.

Entry Conditions
(HL)
(DE)

= Same
= dcb

as

swrite above.

CALL SVERF

Exit Conditions
Z

= OK

a = trsdos

error code.

$PUTEXT— 17483/X

?

444B

?

This routine will add an extension to a filename
exist.

An

extension to a filename

may be

if

an extension does not already

useful for identifying the type of data

in the file.

81

r~"

'

"M

mam

Entry Conditions
= DCB
= The

(DE)
(HL)

extension to be added to the

file

CALL SPUTEXT

Exit Conditions
None

$BKSPC

— 17477/X'444§

This routine positions the

file

9

record pointer to the previous record.

Entry Conditions
(DE) = DCB
CALL $BKSPC

Exit Conditions
z

= Valid position
= Invalid position

nz

in file

$REW1NB — 17471/X
Point to the beginning of the
first

record in the

file.

This

is

file.

9

443F

9

This routine positions the

useful

when

the

same

file

file

pointer to the

must be processed more

than once.

Entry Conditions
(DE)

= DCB

Exit Conditions
z

= Good

file

specification

nz = Bad file specification
CALL SREWIND

$POSEOF

— 17480/X 4448'

Point to the end of
the

82

file.

This

9

file.

This routine positions the

may be used

file

pointer to the last record in

to extend a sequential access

file.

1

TRSDOS
WBBf

tmmmmmm

Entry Conditions
(DE) = DCB
CALL SPOSEOF

Exit Conditions

= Good file
nz = Bad file
z

specification
specification

$SYNTAX— 17436/X 441C
9

Move

a

checks

file

it

specification to dcb. This routine takes a file specification

for validity

and moves

it

to a

dcb

so that the

file

and

may be opened.

Entry Conditions
(HL)
(DE)

= Filename
= DCB

CALL SSYNTAX

Exit Conditions
z

= Good file specification
= Bad file specification

nz

$DIVIDE

— 17489/X'445

The divide routine takes a

16-bit dividend

1

and an eight-bit divisor. After
and the remainder replaces the

division, the quotient replaces the 16-bit dividend
eight-bit divisor.

Entry Conditions
hl = Dividend
A = Divisor
CALL SDIVIDE

Exit Conditions
HL = Quotient
a = Remainder

(0 indicates

no remainder).

83

TRS-80 Ml

feii™*^isJ

t:

$OMULT— 17486/X 444E'
9

The multiply routine uses a

16-bit multiplicand

and an eight-bit multiplier. After

multiplication takes place, the product replaces the 16-bit multiplicand.

Entry Conditions
hl = Multiplicand
A = Multiplier
CALL SDMULT

Exit Conditions

= High order byte
= Middle order byte
a = Low order byte
H

L

H

L

High

Middle

Low

IIR^17©40/X 429!F
9

This routine allows you to examine a diskette directory (one entry or the entire
directory) or the diskette's free space. The information is written into a user
specified

ram

buffer.

Only non-system

files will

be included in the

ram

directory.

Entry Conditions
hl = ram Buffer.
size

=
=

b

c

= 22.

If

c = 0, size
c = 255, size

If

Specified drive

=
=

1761 [max

#*22+

1]. If

c=

number

C

Results

Gets entire directory into ram. (See

ram

Directory Format).

1-96

Gets one specified directory record into ram,
ram Directory Format)

255

Gets free-space information (See

ram

Exit Conditions

= Error occurred.
= No error. (HL) =

if

it

exists. (See

Directory Format).

call sramdir

nz

84

to 96,

Function switch:

Contents of

z

1

64.

directory or free-space information.

TRSDC
1«^—
Sg

RAM Directory Format
The directory is made up of records, one per file. All values
Each record placed in user ram is in the following format:

are hexadecimal.

Byte Number

Contents

0-14
15

filename! ext:d (left-justified followed by spaces)
Protection Level, binary 0-6

16

Byte EOF, binary 0-255

17

Logical record length, binary 0-255

18-19

Last sector

20-21

Number

22

"

+"

number

in file, binary lsb,

msb

of Granules allocated clsb.msb) binary

(marks the end of directory

list

after entire directory.)

Free Space Message Format
***nnnnn Free Granules***

Where nnnnn

is

a decimal number.

The

entire

$FILPTR— 17037/X'428B

message

in conjunction

Ascn-coded.

?

This routine provides information on any user file that
enables you to obtain the drive number and the logical

and should be used

is

is

currently open.

file

number

for

It

any

file

with sramdir.

Entry Condition
(DE)

=

Data Control Block (dcb) defined when

file

was opened.

CALL $FILPTR

Exit Conditions

= Error occurred.
= No error. The following registers are set up:
= Which drive contains the file (0,1,2, or 3).
= Logical file number (1-96)

nz
z
b

c

Note: This operates with user

files only.

$CLOSE— 17448/X 4428
9

?

$close closes a file from the last processing done. It is very important to do
a $close on every file opened before the program ends. If you do not close
a file, the directory entry for this file is incorrect if any new records have been

85

m
1

TRS-80

--"-i

MODEL

il

%

written into the

trsdos

that all

Other cases are not given here, but
of the "housekeeping" be complete for
file.

it

is

file

very important to

management.

Entry Conditions
(DE) = DCB
CALL SCLOSE

Exit Conditions

= OK
a = trsdos
Z

$JKILL

error code.

— 174§2/X 442C
9

skill deletes the directory entry for a

may be open

file

and releases the disk storage. The

or closed; skill will operate in either case.

Entry Conditions
(DE) = DCB
CALL SKILL

Exit Conditions
Z

= OK

a = trsdos

error code.

Additional Routines and Storage Addresses

$JP2D08

— 16429/X'402D

?

This routine transfers control to trsdos ready.

Entry Conditions
JP

SJP2DOS

Exit Conditions
None

86

file

Ti
TRI:

$OATE— 12339/X 3(B3
$TIME— 12342/X 3CI36
9

9

?

9

These routines return the date and time
Date:

mm/dd/yy

Time:

hh/mm/ss

".

S

in ascii format:

Entry Conditions
(HL)

=

Eight-byte buffer to receive the date/time text

CALL SDATE
CALL $TIME

Exit Conditions
(HL)

=

Date or time text

— 16922/X 421 A
$TIMLOC — 169 19/X 4217
IATLOC

9

9

These locations store the date and time

SDATLOC (Three bytes):
STIMLOC (Three bytes):

9

9

in binary format:

yy dd yy
ss mm hh

$EMROSP— 17417/X

9

44t)9

?

This routine displays a trsdos error message determined by the contents of the
accumulator (A). This register contains an error code (0 = no error) after

completion of any system routine.

Entry Conditions
A = trsdos

error code (see Table at the

end of

code, bits 6 and 7 are normally reset

(off).

this section). In

So $errdsp

a trsdos error

interprets

them

as

controls.

Not Set (Normal
Bit

#

Set

Condition)

7

Return to caller upon
completion

Return to trsdos upon
completion

6

Give detailed error message

Give error number only

CALL SERRDSP

wmmmmsmem
87

TF

{Iltl

on
oU

iSK SYSTEi

ii
IV

Exit Conditions
None

Sample Use
ANY SYSTEM ROUTINE
$SYSRTN
CHECK FOR ERROR
ZfOKGO
THE FOLLOWING INSTRUCTION SETS BIT 8 (DETAILED
ERROR MESSAGE) AND BIT 7 (RETURN TO CALLER AFTER
DISPLAYING MESSAGE
BINARY 11000000
OR
C0H
NOW CALL ERROR DISPLAY
$ERRDSP
CALL
CONTINUE HERE UPON RETURN FROM ERROR DISPLAY
YOUR ERROR HANDLER MAY GO HERE

!

!

i

CALL

5

JR

i

5

5

»

J

OKGO

5

CONTINUATION AFTER $SYSRTN WITH NO ERROR

$DSFMR— 17433/X 4419
9

This

command

?

displays the directory listing of

all

non-protected user

files in

specified drive.

Entry Conditions
(X'427r)

=

Ascn-coded drive number "0," "1," "2," or "3"

CALL SDSPDIR

All registers are changed.

IOS— 17049/X 4299
9

This routine executes a trsdos

command and

?

returns to

Entry Conditions
(HL)
JP

=

Text of trsdos

SCOMDOS

Exit Conditions
None

88

command,

terminated by X'OD.'

trsdos ready.

a

TRSDOS

c

**t**mmmsemm

$CMOOOS— 17052/X 429C
?

This routine executes a trsdos

command and

9

returns to the caller.

Entry Conditions
(HL)

=

Text of trsdos

command, terminated by

X'OD;

Exit Conditions
All registers are changed.

Caution: trsdos commands will overlay

ram up

$CMDIXT^ 16933/X 4225
9

to X'6FFF.'

?

This

is the start address of a buffer containing the last
under trsdos ready. Using this buffer, your program

that

were included

in the last

command

command line entered
may recover parameters

line.

For example, given a program named editor/cmd, we want the operator to
select an input file name when the program is loaded and executed from trsdos
ready:

trsdos ready
editor myfile

The program, editor, can recover
Note:

On

entry to a program, (HL)

the

=

name of the

First

file in

the

scmdtxt

buffer.

non-blank character following the

program name.

;NB^17425/X 441F
9

This storage location contains the highest address available. It is normally the
same as the physical end of ram, but you may change it for special purposes.

The address

is

in lsb,

msb sequence.

J^j™iifeiiiMiiliMilli

89

ipm

L

&«'>''

l^^^iB

DBSK SYSTEM
——MODEL
— ————-~^^^~^^^^>^

TRS-80
""~~~
,m

111

TRSDOS Error Codes/Messages
No

Found

Error

1

CRC

2

Disk Drive Not

3

Lost Data During Disk I/O
CRC Error During Disk I/O

4
5

6
7

Error During Disk I/O

"Undefined Error Code**
Disk Drive Not

9

Illegal I/O

11
1

System

Disk Sector Not Found
Disk Drive Hardware Fault

8

10

In

Ready

Attempt

Command Parameter
Illegal Command Parameter
Time Out On Disk Drive
Required

Not Found

15

Attempt To Non-System Disk
Write Fault On Disk I/O
Write Protected Disk

16

Illegal

17

Directory

18

Directory Write Error

I/O

1

14

Read

Error

19

Invalid File

Name

20

GAT Read
GAT Write

Error

21

22
23
24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41

90

Number

Logical File

Error

HIT Read Error
HIT Write Error
File Not Found
File Access Denied Due

to

Space Full
Space Full
Attempt to Read Past EOF
Attempt to Read Outside of
No More Extents Available
Program Not Found

Password Protection

Directory

Disk

Invalid Drive

File Limits

Number

"Undefined Error Code"
Attempt to Use Non-program File as a Program
Memory Fault During Program Load
"Undefined Error Code"
File Access Denied Due to Password Protection
I/O

Attempt to Unopen

Invalid
File

Command

Already

Attempt to

In

File

Parameter

Directory

Open

File

Already

Open

•hi!

IIP

m
m

Mtt9

^^*giiipip«»s»«,,

'

Introduction
Start-Up
Under trsdos ready,

type:

BASIC

CENTER)

trsdos

will load basic

If

and begin the "initialization dialog."

you want to recover a Disk basic program after returning to trsdos
trsdos command, use this command under trsdos ready:

for a dir

or other

BASIC

*

CENTER )

You

will go directly to Basic's ready mode without any initialization dialog. If
you had a program in memory, it should still be there. You may not be able to
run the program. To be safe, you should immediately save the program, go to
trsdos, then start basic again (no asterisk).

Note:

If

you have overlaid user memory while in trsdos, your program will be
you should not restart basic, but should use the normal

erased. In such a case,

basic start-up procedure.

Initialization
When you

Disk basic, you are

first asked, HON MANY FILES?. This lets
you specify the maximum number of files that will be "open" or in use at once.
(See o pen.) Type in an appropriate number and press CENTER) or simply press
CENTER) and basic will provide for three files.

start

,

a«.j

For example, if your program requires one input
should ask for two files.

file

and one output

file,

you

Note: Normally, basic will give all your data files a record length of 256.
(See File Access Techniques.) If you wish to set the record length of each
individually, use the suffix v for "Variable" after the number of files.

file

For example,

HOW MANY FILES? 3M
tells

each

CENTER)

basic to give you three lie-buffers, and to
file when that file is first opened.

let

you

set the

record length of

Note: Disk basic automatically creates a buffer for loading, saving, and
merging basic programs. This buffer exists in ram below any data file buffers
you may request. It is always available for program i/o, regardless of how you

II

answer the files? question.

WRB&

B»fl-.!

91

p

*

ODEL

ISI

DISK SYSTEI

After you answer the files question, basic will ask:
press (ENTER) without typing a number.

You

will then

MEMORY SIZE? Simply
have the maximum amount

of

ram

If

you will want to load and use machine-language programs or routines, you
have to protect your basic memory from these machine-language programs.

available for use

by basic.

will

memory address (in decimal form) you
want basic to use for storing and executing your basic programs. Addresses
above the number you specify will then be protected from use by basic.
In such a case, respond with the highest

Example:
MEMORY SIZE? 32000 dMIER)
causes basic to protect addresses above 32000. If you have 16K of ram, this

have 32767-32000
machine-language routines.

means

that you'll

After you answer the

=

MEMORY SIZE?

767 bytes protected

for storing your

question, Disk basic will display the

following information:
1

Which

2.

Copyright information

3.

The number of free bytes

4.

The number of concurrent

To

exit

CMD"S"

version of Disk basic you are using

available
files

you have requested.

from Disk basic and return

to the

trsdos ready mode,

type:

(ESTER)

This results in a normal return to trsdos, without re-initialization of the system.

You may recover your program
trsdos. Use basic *.

92

if

you haven't changed user memory while

in

^SKSi..;--;

Enhancements

to

W BASIC

Mode!

Disk basic adds many features which are not disk-related. They are

listed

below

along with abbreviated descriptions. Detailed descriptions follow in alphabetical
order.

&H
&o

Octal-constant prefix

Abbreviations

Many commands have

CMD"A"
CMD"B"
CMD"C"
CMD"D"
CMD"E"

Return to trsdos with error message

Hexadecimal-constant prefix

CMD'T'
CMD"J"

CMD"L"
CMD"0"
CMD'T"
CMD"R"
CMD"S"
CMD'T"
CMD"X"

abbreviations

Enable/Disable (BREAK)
Delete spaces and remarks from a program (compression)
Display directory for specified drive

Display previous trsdos error

Return a

command

to

trsdos

Convert calendar date

Load

program

z-80 subroutine or

file

into

ram

Alphabetizes (sorts) a string array only

Check

printer status

Start real-time clock display

Normal

return to trsdos (jump
Turn off real-time clock display

to

exit routine)

Cross-reference of reserved words, string variables, or
strings in a

program

CMD"Z"
DEFFN

Duplicate output to Display and Printer

DEF USR

Define the entry point for an external machine-language

Define basic- statement function
routine

INSTR

Instring function; find the substring in the target string

LINE INPUT

Input a line from keyboard

MID$ =

Replace portion of the target

string (used

on

left

of equals

sign)

NAME

Renumber

USRrt

Call external routine («

ram
= 0,1,2,

a program in

... ,9)

&H and &O (hex and octal constants)
Often

it is

convenient to use hexadecimal (base 16) or octal (base 8) constants

rather than their decimal counterparts. For example,

values are easier to manipulate in hex form.

memory addresses and byte
&h and &o let you introduce such

constants into your program.

&h and &o

are used as prefixes for the numerals that immediately follow them:

93

ODEL

ill

DISK SYSTEI

tMdddd
dddd is a

1 to

4 digit sequence composed of Hexadecimal numerals

0,1,...9,A,B.....F.

&oddddd
ddddd is

a sequence of octal numerals 0,1, ...J and

&oddddd< = 177777

decimal.
Note: The o can be omitted from the prefix &o. Therefore &oddddd=.&ddddd.

The constants always

number
number greater than &.QI1111, will be
negative quantity. The following table illustrates this:
represent signed integers. Therefore any hex

greater than &H7FFF, or any octal
interpreted as a

Hex

Octal

&1

&H1

&2
&77777
& 100000
& 100001

&H2
&H7FFF

32767

&H8000
&H8001
&H8002

-32768
-32767
-32766

&HFFFE
&HFFFF

-2

&1 00002
& 177776
& 177777

Hex and

Decimal

octal constants cannot

or be contained in a

data

be typed

1

2

-1

in as responses to

an input prompt

statement. Often the hex or octal constant must be

enclosed in parentheses to prevent a syntax error from occurring.

Examples
PRINT &H5200* &O51000
prints the

decimal equivalent of the two constants (both equal 20992).

POKE &H3C00, 42
puts decimal 42 (ascii code for an asterisk) into video

memory

3C00.

mm
94

SB

address hex

"]!

HOI/''

»»m

Mode!

Ill

Disk

®
©

List

CD
CD
(SHIFT)
(SHIFT)

Current Program Line

Program Line
Program Line
List Last Program Line
List Program Line xx
Edit Program Line xx
Delete Program Line xx
Automatic Line Numbering Beginning
Incrementing by xxxx.

ucx

DXX
AXXX,XXXX

CMD"A'

Next Program Line

List

List First

EXX

Return

Previous Program Line

List

Edit Current

©
©©

,&

Abbreviations

Meaning

Abbreviation

This

BASIC

DJtDI^I

at Line xxx,

A 99

to

TRSDOS

:

command

allows you to return to trsdos with an error message:

OPERATION ABORTED

Sample Use
After an input/output error occurs in a basic program, you might want to exit to
print a message.

trsdos and

CMD"A"
the following will be displayed:

OPERATION ABORTED
TRSDOS READY
4t»ttt*4<4*t*4*»tft

95

,

""RS-80

s

MODEL

ill

DISK SYSTEM

CMD "B"
BREAK Key

Enable/Disable

cmd"B",

'switch'

switch

This

is

either on or off. switch

must be enclosed

in

quotation marks.

command

the (BREAK)

enables or disables the (BREAK) key. While the function is "off,"
key will be ignored except during cassette or printer output or during

serial input/output.

The

(BREAK)

key

will remain disabled even after the

enable the (BREAK) key, use the cmd"B","ON"
via the

cmd"S"

or

cmd'T' commands

program has ended. To
to trsdos

command. Returning

will also enable the (BREAK) key.

Examples
CMD"B" »"0FF"
Disables the (BREAK ) key.

CMD"B" »"0N"
Returns the (BREAK) key to

its

normal function.

CMD "C"
Compress Program

crvtD '%',

options

options

may be

either r (delete remarks) or s {delete spaces).

options are omitted, remarks and spaces are deleted.

If

If

both

only one

owittec?, only the specified action is lakes.

command allows you to compress a program so that it requires less
ram and less storage space on diskette. You can elect to remove all remark

This

96

is

DISK BASIC

statements (beginning with

rem

or

')

or to delete

all

|

spaces between basic

keywords. Spaces inside quotes will not be deleted.

Example
Your program reads

850
8B0
870
880
If

as follows:

RESTORE: ON ERROR GOTO 800 'DOG PROGRAM
READ COMPANY*
'PET STORE
PRINT RIGHT$(C0MPANY*»2> >: GOTO 860
END

you want

CMD"C"

to delete the

If

(lines

850 and 860), type

in the

command:

.R

and the program will

850
860
870
880

Remarks

now

read:

RESTORE: ON ERROR GOTO 800
READ COMPANY*
PRINT RIGHT*(C0MPANY*»2) »:G0T0 860
END

you then wanted

CMD"C"

to delete the spaces, type in:

,S

and the program would read:

850
860
870
880

RESTORE ONERRORGOTO800
READCOMPANY*
PRINTRIGHT*(C0MPANY*»2) »:GOTO8S0
:

END

You could obtain

the

same

results

by typing:

CMD"C"
Note: Always provide the closing quotes on string literals in your basic
program. Otherwise cmd"C" may not function properly. For example, in
10

PRINT "THIS IS

A

TEST"

the second quote should be used even though omitting

it

will not cause

an

error.

CMD"D"
Display the Directory of a Specified Drive

mo"o:d"
d

is

/

";

the drive specification

97

By

command cmd"d:<5P' you can obtain a specified diskette's
from basic without returning to trsdos. Only unprotected, visible
be displayed. The drive specification is not optional and must be

entering the

directory
files will

,

specified for all drives, including Drive 0.

Example
If

you type

in the

command:

CMD"D:1"
the directory for Drive

1

will

be displayed.

TRSDOS error

Display Previous

CMD"E"

This command displays the last trsdos error message. If no errors have
occurred prior to the command, the message NO ERROR FOUND will be
displayed.

Example
If

you have a two-drive system

(0

and

1)

and you type:

SAME "PROGRAM: 3"
I/O ERROR To find out what kind of

Disk basic will return a D I SK
occurred, type: CMD

E
"

"

(

.

ENTER) and Disk basic will return with

I/O error

DISK DR I VE

NOT IN SYSTEM.

CMD"I"
Execute TRSDOS Commands from Disk BASH

mo"\",

''

command

command is

,

a string expression containing a trsdos

program
quotes.

98

'

,

file

name.

If it

is

a string constant,

it

command

or a z-80

must be enclosed

in

You may execute trsdos commands
This

is

cmd"S", except
trsdos to execute

similar to

program

for

directly

that

it

lets

from basic by using cmd'T'.

you include

a

command

or z-80

As long as basic is not overwritten by the execution of the program or
command, control will return to basic; otherwise, control will return to trsdos.
(trsdos commands all overlay basic; your z-80 program may not if it loads
above basic.)

Example
CMD"I" ("PROGRAM"
returns

CMD"!"
returns

you

to

trsdos and executes the program

to

trsdos and executes the command contained

file

program.

>M
you

in a$.

CMD" J"
Calendar Date Conversion

cmd"J", source, destination

source

is a string

expression containing the date to be converted.

may be

contents
as

mm/dd/yy

bj

-yy/ddd

in either of

Format a gives the date

in

the day of the year (from
the hyphen

destination

is

Is

Its

two formats:

month-day-year sequence. Format

1 to

365 or 366

for leap years), In

b gives

format

b,

required.

a string variable to contain the converted

format

a,

destination will contain the day of year.

format

b,

destination will contain the elate

in

Me.
If

format

If

source

source

Is in

is in

a.

command converts dates back and forth between two formats: the standard
month, day, year, sequence; and a year, day of year, sequence. The content of
the source string determines which way the conversion goes

This

itiijfiiaMiiiiiiiiiiiiiiiMaii^i^

99

iSwil

:

LJ g TRSjO MODEL

JBB

DISK SYSTEj

Example
CMD"J"

"11/30/80"

>

>

D$

Returns the day of the year in d$.

CMD"J"

"-79/300"

,

,

D$

Returns the month, day, year, equivalent

in

D$ (the date for the 300th day

of 1979).

Sample Program
10 CLEAR 50
20 LINE IN PUT "ENTER FIRST DATE (MM/DD/YY) "5 FD$
30 LINE INPUT"ENTER SECOND DATE (MM/DD/YY) "?SD$
40 CMD"J"
FD$» Dl$
t

50 CMD"J"
B0
70
B0
90

Yl

=

Y2

=

Jl

=

J2

=

40
50
G0

SD$> D2$

)

)

1*365 + Jl
= Y2*3G5 + J2
PRINT "THE INTERVAL BETWEEN DATES IS"
PRINT ABS(S1-S2)i "DAYS "5
PRINT "(IGNORING LEAP-YEARS),"
INPUT " TO CONTINUE"
A$
GOTO 20

00 SI
10 S2
20
30

>

MAL(RIGHT$(FD* ,2)
UAL(RIGHT$(SD$,2)
VAL(RIGHT$(D1* ,3)
MAL(RIGHT$(D2$>3)
=

Y

5

CMD"I
Load

9

Z=8(Q)

Routine imto

RA

cmd"L", mtiiim
routine

is

a string expression containing a

routine or program created by the
string constant,

CMD"L"

it

must be enclosed

specification for a z-80

in

is

to

If

routine

is

a

quotes.

loads a z-80 (machine- language) routine into ram.

be used to load a z-so subroutine which

100

file

dump command.

It

would normally

be accessed directly from basic.

nOHK

The

z-80 routine should load into

protect area reserved

when you

high-RAM and must not overlay the memory

first

entered basic

(i.e.

,

the

MEMORY SIZE?

prompt). If you do not overlay basic or trsdos, control will return to basic
after the

program

is

loaded.

Example
The command:
CMD"L" »"PR0G"
will load a

program

file

named prog

into

ram.

CMD"L" ,P$
will load a

program which has been

CMD"0

9 '

Sort ("Order'

cm"Q",x,array

x

is

specified as p$.

9

)

am Array

(start)

an integer variable containing the namiier

amy (start) specifies an array element.
sorted, and

of

items to he sorted.

The array contains the data

start is the suiissript of the first

element

to

to

array most be one-dimensional, siring type. The string elements
array

This

command

may

sort all or part

may be

of

sorts (orders) a

be

he sorted. Tins
in

any length.

one-dimensional string array,

i.e.,

a

list.

You

of the array, depending on the values you give to x and

start.

Sample Program
10

20
30
40
50
G0
70
80
90

CLEAR 10 * 25 + 50
'ROOM FOR 10 WORDS
DIM A* (9)
'LIST OF TEN (0-9)
FOR WD =
TO 9
PRINT "ENTER NORD «"
WD+1
INPUT A*(WD>
NEXT WD
HI, A*(0)
NZ = 10; CMD"0"
PRINT "HERE IS THE SORTED LIST
FOR WD=0 TO 9

+

EXTRA

5

>

BttatSiftk

101

iim
u %i4'

'~4i$

hP

B'-itU

xg»' &L#

Issai fe^^i

b!

i

!J

a^y k

^^ ^
to

fe?

sS

^W^

!3

OWs

&i

100 PRINT A$(WD!
110 NEXT WD

CMWV
Check

Pi

'

status

cmd'T" makes

it

vier Status

is

a string variable

possible for Disk basic to check the status of the printer.

Unlike the video display, the printer
disconnected, offline, out of paper,

is

not always available.

etc. In

such cases,

It

may be

when you

try to output

information to the printer, the Computer will wait until the printer becomes
available.

It

will appear to

"hang up." To regain keyboard

the printer operation), press (BREAK)

control (and cancel

.

Suppose you have a program which uses printer output. If a printer is not
available, you don't want the Computer to stop and wait for it to become
available. Instead, you may want to print a message such as PRINTER
UNA MAILABLE and go on to some other operation.
this, you need to check the printer status. cmd"P" can be used to
check the printer's status at any time. It returns the contents as an Ascii-coded
decimal number. The specific value of this number depends upon the type of
printer you are using as well as its status at any particular time. The value may
then be printed or examined by the program.

To accomplish

Only the four most significant bits
these must be: "0011" or else the

are used in this "status byte." In binary,

To
check for this "go" condition, and the status byte with 240 and compare the
result with 48. The meaning of each status bit depends on which printer you
use. See the printer owner's manual for bit designations.
print operation will not be attempted.

Sample Program
10

CHD"P"

,}{$

20 SJ1 = VAL(X$) AND 240
30 IF STX <> 48 THEN PRINT

"PRINTER UNAVAILABLE": STOP

40 PRINT "PRINTER AVAILABLE"
50 REM PROGRAM MAY NOW CONTINUE

102

iH

C^ %./f

lc5>

Pi

£?

13l\ ol^kS
WllgsMiSiii

CMD E"
66

TUmirn

On Clock-Display

CMD"R"

This

command

controls the real-time clock display in the upper-right corner of

Video Display. When it is on, the 24-hour time will be displayed and
updated once each second, regardless of what program is executing.
the

Note: The real-time clock is always running (except during cassette or disk
regardless of whether the display is on or off.

i/o),

Example
To turn on the clock display

type:

CMD " R " To turn the display

off, type:

CMD " T

CMD"S"
Return! to

TRSEM

..'

5

CIWD"S"

To

exit

from Disk basic, returning control

to

trsdos, simply type

in the

command:
CMD"S"
To return to basic and recover your program, use BASIC
will not always be possible. See basic *.

The basic prompt

lets

you know you

are in

*.

However, recovery

Disk basic.

READY

103

\

TRS-80

..'~Y:

^™

\;-f4

To

exit,

type

MODEL

BBS

PflSBC

S YSTEM

in:

CMD"S"
and the trsdos prompt will appear.

TRSDOS READY

CMD"T"
Ikm Off Clock-Display

CMD"T"

This

command

turns off the real-time clock display function.

However, the clock continues

to run.

Example
To stop the clock display update
To

type:

CMD"T"

CMD"R"

start the display, type:

CMD "X"
j

Cross-refferai

cmd

c

off

PVogramn Limes

"X", target

target is either a basic reserved word (such as primt) or a string-literal.
is

a reserved word,

literal,

104

it

it

must not be enclosed

must be enclosed

In

quotes.

in

quotes;

if

it

is

If it

a string-

fmmmMmmmmmmmmmmammmammmammammmmmmmmmmmm

This

command

finds

all

the resident program.

occurrences of a reserved word or other string

The "finds"

are listed

on the display as

llftigSiiiiligil^S^

literal in

five-digit line

numbers

To search for any basic reserved word (including reserved arithmetic operators),
use the keyword as-is. To search for anything else (including variable-names and
text),

enclose the text inside quotes.

For example, suppose you have the following program

PRINT "THIS IS

10

A

in

memory:

TEST"

20 INPUT "PRESS  FOR THE NEXT PRINT MESSAGE"
30 A = A + 1
40 PRINT "+++++++"

5

Z$

CMD "X"
PRINT will find all occurrences of print, except for cases where
print was part of a quoted string: lines 10 and 40.
i

CMD "X"

"PRINT"

will find all occurrences of

+ will

line 30, but

>

"print"

as a string literal: line

20.

CMD

")!",

"A" will

list

lines 10, 20,

list

" + " will list line 40. CMD
CMD "X"
"X"
and 30. Notice that variables and text are both treated
,

»

as string literals.

CMD "Z

9?

Duplicate Output to Video and Printer

cmd"Z", "switch"

switch

This
is

command

"on,"

is either

ow or off. switch must he enclosed

in

quotation marks.

enables or disables dual video/printer output. While the function

is copied to the printer, and all printer output is copied
(The printer must be on-line when you turn dual output "on.")

video output

all

to the video.

Video and printer output may

differ

due to

intrinsic differences in the printer

and

video devices.

Examples
CMD "Z"

>

"ON"

Turns dual video/printer output on.

105

MODEL

TRS-80

DISH

111

CMD"Z"j "OFF"
Turns dual video/printer output

off.

OFF FN
Delne Function

tie

m

n

r-i

im

thai'M

'•

Ian nam;

r

r~r r

.

,

i

i

„

ij

i

in

.

!

/:

!»

i

hat

liie

tanclioa fioes.

Minidia

Etis

The deffn statement
have

new

to call the

lets

o:

you can

u!i"-.

!

'-<

sign.

you create your own function. That

is,

call

it

Once

a function has been defined with the

deffn

simply by inserting fn in front of function name. You

can use it exactly as you might use one of the built-in functions,
and strings.

The type of

you only

function by name, and the associated operations will

automatically be performed.
statement,

le

variable used for function

function will return. For example,

like sin,

abs,

name determines the type of value the
name is single precision, then that

if function

function will return a single-precision value, regardless of the precision of the

arguments.

The

particular variables

(argument- 1,
later,

.

.

.)

you use

as arguments in the

are not assigned to the function.

def fn statement

When you

call the function

any variable name of the same type can be used.

in a deffn statement has no effect
on the value of that variable. So you can use that particular variable in another
part of your program without worrying about interference from def fn.

Furthermore, using a variable as an argument

The function can be defined with no arguments

at all, if

none are required.

For example:

DEF FNR

=

RND

(90)

+

9

defines a function to return a

106

random value between

10 and 99.

Examples
DEF FNR(AtB)

A

=

+

INK

(B

-

(A

-

i>)

*

RND<0))

This statement defines function fnr which returns a random number between
integers A and B. The values for A and B are passed when the function is
"called," i.e., used in a statement like:
Y

FNR(R1

=

If ri

R2)

,

and R2 have been assigned the values 2 and

random number between 2 and 8
DEF FNL* B«)
Defines function
the difference
the function

is

=

(A*

fnx# which

between

a#

-

B#)

*

(A#

-

B»)

returns the double-precision value of the square of

and b#. The values for

a#

and

b#

are passed

when

called:

FNX#(A#» B#)

S#

=

We

assume

that values for

a#

and

b#

were assigned elsewhere

in the

program.

Sample Program
710 DEF FNM(T) = (1087 + S0R(Z73 + T))/1G,52
720 INPUT "AIR TEMPERATURE IN DEGREES CELSIUS"! T
730 PRINT "THE SPEED OF SOUND IN AIR OF" T "DEGREES
CELSIUS IS" FNY(T) "FEET PER SECOND,"

107

UH

'

V

"

"'--I

TRS-80

MODEL

Sii

DISK SYSTEM

DEFUSE
Define Point of Entry for

=

defusrw

USR Routine

address

n equals one

of the digits 0, 1,...,S;

if

n

is

omitted,

is

assumed, address

specifies the entry address to a machine-language routine, address

must

the range [-32768,3275?!. address

fee in

expression or constant from

-32718

to

may be any numeric

32767.

defusr

lets you define the entry points for up to 10 machine-language routines.
non-Disk basic, the addresses were POKEd into ram. This poke method
cannot be used in Disk basic.

In

Examples
DEFUSR3

=

&H7D00

assigns the entry point X'7D00',

program

DEFUSR

calls

32000 decimal,

to the

USR3

call.

When

USR3, control will branch to your subroutine beginning

your

at

X'7D00\

(BASE + 1G)

=

assigns start address (base

+

16) to

the usro routine.

When

decimal addresses are given, they are evaluated as signed two-byte
integers. So, for addresses above 32767, use desired decimal address -65536.
Note:

See usm«.

INSIR
Search for Specified String

instr (position, siring

1,

string 2)

position specifies the position in string 1 where the search
position

is

optional;

if it

is

is to

begin.

not supplied, search automatically begins

at the first character in string 1. (Position 1 is the first character in

string 1.)

108

*"iHftfe
'illliP

"

.'

:.__^_

sfr/flg I is

string

This function
If

it

2

is

. . .

the string to

lie

searched.

the substring you want to search

you search through a

lets

for.

string to see if

contains another string.

it

does, instr returns the starting position of the substring in the target string;

otherwise, zero

is

returned.

Note

must be contained

that the entire substring

returned. Also, note that instr only finds the

the search string, or zero

is

occurrence of a substring

at the position

you

in

first

specify.

Examples
In these examples, a$

=

"Lincoln":

INSTR(A*, "INC")
returns a value of 2.

INSTR

"12")

(A*»

returns a zero.

"LINCOLNABRAHAM")

INSTR (A*.

returns a zero. For a slightly different use of instr, look at

"1232123"

INSTR (3.

"12")

,

which returns 5

This program gets search and target text from the keyboard, then locates
occurrences of the target text in the search
10 CLEAR
20 CLS
30 INPUT

40
45
50
60
70
80
90

=

F

=

C

COUNT

for

is just

all

"show."

S$
SEARCH TEXT"
TARGET TEXT"! T$
i

:

P

=

1

'P

=

IF F

INSTR(P»S$»T$)
=
THEN 120

C

C

=

Line 90

1000

INPUT
CLS
C

text.

+

POSITION*

1

PRINT i0,LEFT$(S$»F-l) + STRINGS LEN( T$
RIGHT* (S*»LEN(S$)-F-LEN(T$)+1)
100 P = F + LEN(T$)
110 IF P <= LEN(S$) - LEN(T*) + 1 THEN G0
120 PRINT "FOUND "i Ci "OCCURRENCES"
(

)

,

191

)

+

—HI
109

TRS-80

MODEL

111

DISK SYSTEM

LINE INPUT
Jfaiput

a Line from Keyboard

line input

"prompt" ;variable

prompt is
variable

a prompting

is

the

name

line input (or lineinput

The Computer

—

message.

that will be assigned to the fine

the space

is

optional)

will not display a question

is

you type

in.

similar to input, except:

mark when waiting

for your

operator's input.
•

Each line input statement can assign a value

•

Commas

•

one variable.

to just

and quotes your operator can use as part of the

Leading blanks are

The only way

not ignored — they become

to terminate the string input

is

string input.

part of variable.

to press

(

ENTER)

.

is a convenient way to input string data without having to worry
about accidental entry of delimiters (commas, quotation marks, colons, etc.).
The (EHTER) key serves as the only delimiter. If you want anyone to be able to

line input

input information into your program without special instructions, use the line
input statement.

Some

situations require that

you input commas, quotes and leading blanks

as

part of the data, line input serves well in such cases.

Examples
LINE INPUT A*
Input a$ without displaying any prompt.

LINE INPUT "LAST NAME) FIRST NAME?
Displays a prompt message and inputs data.
input string, as they

would

5N$

Commas

in an input statement.

Sample Program
200 REM CUSTOMER SURVEY
205 CLEAR 1000
207 PRINT

110

"

will not terminate the

ilL

210
220
230
235
240
250
260
270

LINE INPUT
LINE INPUT
LINE INPUT
PRINT
PRINT A$

"TYPE IN YOUR NAME "5 A*
"DO YOU LIKE YOUR COMPUTER?
"WHY? "
C$

"5

B$

5

PRINT
THEN 270
LIKE MY COMPUTER BECAUSE "5 C$ ;END
DO NOT LIKE MY COMPUTER BECAUSE "5 C$
i

IF B$ =

PRINT
PRINT

"NO"
"I
"I

Notice that

when

statement,

"Type

question

210 is executed, a question mark is not displayed after the
your name." Also, notice on line 230 you can answer the
with a statement full of delimiters, commas and quotes.

line

"Why"

in

Eeplace Portion of String

mids (iUsiring, position, length)

=

replacement-string

oldstring is the variable-name of the string you want to change.

position

is tine ojimiSiic

expression specifying the position of the

first

character to be changed.

length

is

a

numeric expression specifying the number

of characters to

be

replaced.

replacement-string

is

a string expression to replace the specified portion

of oldstring.

Note:

If

replacement-string

string will

is

shorter than length-, then the entire repiacement-

used.

tie

lets you replace any part of a string with a specified
giving you a powerful string editing capability.

This statement

Note

that the length of the resultant string is

new

string,

always the same as the original

string.

Examples
a$

=

"Lincoln"

MID$(A$» 3,

in the

4)

=

examples below:

"12345":!

PRINT A$

which returns LH234N.

111

I

iS TOS-80 MODEL

ill

DISK SYSTEM

WHtKSBBSk^^

MID$(A$»

1

Z)

t

"":

=

PRINT A$

which returns Lincoln.

MID$(A*»
returns

5)

=

"12345":

=

"01";

PRINT A$

lino 23.

MID$(A$,

5)

PRINT A$

returns lincoin.

HID$(A$»

1

3)

>

"*##":

=

PRINT A$

returns ***coln.

Sample Program
770
7B0
790
800
B10
820

PRINT: PRINT
LINE INPUT "TYPE IN A MONTH AND DAY MM/DD,
P = INSTR(S$, "/")
THEN 780
IF P =
MID*(S*» Pt 1) = CHR*(45)
PRINT S$ " IS EASIER TO READ. ISN'T IT?"
CLS:

This program uses instr to search for the slash ("/").
(if

it

finds

it), it

uses

mid$ = to

substitute

a "

—"

When

"5

it

(CHR$(45)) for

5$

finds

it

it.

NAME
Eem

? i

n 1

>

b

1

name newline,

fti

e

C 'vjrireiiit

startline,

increment

newiine specifies the new
If

omitted, 10

is

line

number

of the first line to

be renumbered.

used.

startline specifies the line

renumbering

Program

number

will start.

If

in

the original program

where

omitted, the entire program will be

renumbered.
increment specifies the increment

number.

112

If

omitted, 10

is

to be

used.

used between each successive

line

n j§§c

HA

e

10

Examples
NAME
Renumbers

the entire program: 10, 20, 30,

.

.

.

NAHE 6000,5000 »100

Renumbers all lines numbered from 5000 up; the first renumbered line
become 6000, and the following lines will be incremented by 100. All
references within your program will be renumbered also.

will
line

USRm
Call to User's Exi ernal

usr/j

^r

broi

tin

2

(nmexp)

where n specifies one
omitted, zero

is

oS ten available

nriiexp is an integer from

argument

usr calls, 0=0,1,2,. ..,9.

If-ffis

assumed.

-327S8

to

32757 and

is

passed as an integer

to the routine.

These functions (usro through USR9) transfer control

to

machine-language

routines previously defined with defusrjj statements.

When

a urs call

is

encountered

in a statement, control

goes to the address

specified in the defusrtj statement. This address specifies the entry point to your

machine-language routine.
Note: If you call a usrh routine before defining the routine entry point with
DEFUSRn, an illegal function call error will occur.

You can pass one argument and retrieve one output value directly via the usr
argument; or you can pass and retrieve arguments indirectly via poke and peek
statements.

Example
1.0

DEFUSR1=&H7D00

20 REM,, .MORE PROGRAM LINES HERE
100 A=USR1(X)

The

effect of this sequence

is to:

113

si-Mi

1

Define usr as a routine with an entry point

2. Transfer control to the routine; the value

routine
3.

makes

the

at

hex 7D00

(line 10).

x can be passed

call described below

to the routine if the

(line 100).

A may contain the value
passed back from the routine (if your routine makes the jump described
below); otherwise A will be assigned the value of x (line 100).

When

the routine returns to basic, the variable

USR routines

Passing arguments to and from

There are several ways to pass arguments back and forth between your basic
main program and your usr routines: the two major ways are listed below.
1.

the argument(s) into fixed ram locations. The machine-language routine
can then access these values and place results in other ram locations. When
the routine returns control to basic, your program can peek into these
addresses to pick up the "output" values. This Is the only way to pass two

poke

or
2.

more arguments back and

forth.

Pass one argument to the routine as the argument in the usRn call, then use
special rom calls to access this argument and return a value to basic. This
method is limited to sending one argument and returning one value (both
are integers).

rom

Calls

call 0A7FH Puts

the

usr argument

into the

hl

register pair;

contains lsb. This call should be the

first

H

contains msb, l

instruction in your

usr

routine.
jp

0A9AH

Use

this

jump

hl becomes the
you don't care about returning hl, then

to return to basic; the integer in

output of the usr

call. If

execute a simple RETurn instruction instead of

this

jump.

an assembled program to white out the display (an "inverse"
clear key!). Don't type it in. Type in the basic program that follows it.
Listed below

is

00100
00110
zap OUT
00120
00130
00140
EQUATES
00150
001G0
00170 VIDEO
00180 WHITE
00190 COUNT
00200
PROGRAM
110
00220
i

;

SCREEN USR

FUt

5

7D00

ORG

7D00H

E0U
E0U
EOU

3C00H
0BFH
3FFH

5

i

!

3C00
00BF
03FF

5

START OF VIDEO RAH

iALL WHITE GRAPHICS BYTE
?

NUMBER OF BYTES TO MOVE

9

!

114

CHAIN MOVES X'BF' INTO ALL OF VIDEO RAM

"^'^wwiig

g

DISK BASIC

21003C
3BBF
11013C
01FF03
EDB0

7D00
7D03
7D05
7D0B
7D0B

00230 ZAP
00240
00250
002B0
00270
00280
00290
00300

1

LD

HL.UIDEO

LD

(HL> .WHITE

iPUT OUT 1ST BYTE

LD

DE.VIDEO+1
BC, COUNT

.DESTINATION ADDRESS
.NUMBER OF ITERATIONS

LD

LDIR

i

SOURCE ADDRESS

.DO

IT TO

IT!

!

!

.

7D0D C9
7D00

This routine can be POKEd into

RET
END

ram and

5

RETURN TO BASIC

ZAP

accessed as a usr routine. First

MEMORY SIZE question with 31993. Then run

start

basic and answer the

the program.

100
PROGRAM: USR1
110
EXAMPLE OF A USER MACHINE LANGUAGE FUNCTION
115
DEPRESS THE '1' KEY WHILE NUMBERS ARE PRINTING TO STOP
120
******* POKE MACHINE PROGRAM INTO MEMORY *******
130
140
150 DEFUSR1 = &H7D00
160 FOR X = 32000 TO 32013
'7D00 HEX EQUAL 32000 DECIMAL
170
READ A
180
POKE X» A
190 NEXT X
192
******* CLEAR SCREEN & PRINT NUMBERS 1 THRU 100 *******
194
19G
'

'

'

'

'

'

'

'
'

200
205
2i0
220
225
230
240
250
260
270
280
290
300
310
320
330

Run

CLS
PRINT TAB (15)? "WHITE-OUT USER ROUTINE":
FOR X = 1 TO 100
PRINT X!
A$ = INKEY*: IF A$ - "@" THEN END
NEXT X

PRINT

'

'

******* JUMP TO WHITE-OUT SUBROUTINE *******

'

= USR1
(0)
FOR X = 1 TO 1000:
GOTO 200

X

NEXT

X

'DELAY LOOP

'

'

******* DATA IS DECIMAL CODE FOR HEX PROGRAM *******

'

DATA 33.0.60,54.191 .17.1 .60.1 .255. 3,237.176,201
the program.

An equivalent

basic white out routine takes a long time by comparison!

115

Disk-Related Features
Disk basic provides a powerful set of commands, statements and functions
under trsdos. These fall into two categories:

relating to disk i/o
1.

File manipulation: dealing with files as units, rather than with the distinct

records the
2. File access:

files

contain.

preparing data

Under the heading,
commands.

files for i/o;

reading and writing to the

we

File Manipulation,

will discuss the following

kill

Delete a program or data

load

Load

MERGE

Merge an Ascii-format basic program on

a basic

files.

file

from the disk

program from disk
disk with one

ram

currently in

run "program"

Load and execute

save

Save the resident basic program on disk

Under the heading, File Access, we

a basic

program stored on disk

will discuss the following statements and

functions.

Statements

OPEN

Open

CLOSE

Close access to the

INPUT

#

a

file

Read from

for access (create the

disk, sequential

mode

Read a

PRINT#

Write to disk, sequential

HELD

Assign

GET

Read from

PUT

Write to disk, random access

LSET

Place value in specified buffer
right to

RSET

of data, sequential

field sizes

disk,

fill

fill

mode

mode

and names

to

random-access

file

buffer

random access mode

mode
field,

add blanks on the

field,

add blanks on the

field

Place value in specified buffer
to

necessary)

file

LINE INPUT#

line

file if

left

field

Functions

CVD

Restore double-precision number to numeric form after
GETting from disk

CVI

Restore integer to numeric form after GETting from disk

CVS

Restore single-precision number to numeric form after

EOF

Check

LOC

get current record number.

GETting from disk

116

to see if

end of

file

encountered during read

lof

Return number of

mkd$

Convert double -precision number
on disk

mki$

Convert integer

mks$

Convert single-precision number to string so
on disk

last

record in

to string so

it

file

to string so

it

can be put

can be put on disk
it

can be put

117

JS

TBS-80

MODEL

DBSK SYST EM

111

Fie Manipulation
KILL
Fie from the Disk

Delete a

kill

exp$
exp$ defines a

command works
Commands.

This

file

specification far an existing

like the

trsdos kill command

file.

—

see

trsdos Library

Example
KILL"0LDFILE/BAS.PSW1"
deletes the

Do

file

specified

not kill an open

close the open

from the

file,

or you

drive which contains

first

may

it.

destroy the contents of the diskette. (First,

file.)

LOAD
Load BASIC Program

File

from Disk

torn exfl${fil

where exp$ defines a filsspec
r \h^:

This

command

b,„' *s

118

i*.

the

program

loads a basic program

afti

file

run the program
command mode.

basic will proceed to
return to the

b bs

for a basic

i

i!

into

is

program

file

stored on disk.

loaded.

ram;

if

the

r option

is

used,

automatically; otherwise, basic will

i^pifiiiiMl

Ha^i^MPin

&miB&*®ttia&m&8&sfflNat&i&

load without

the r option clears all variables and closes all open files,
with the r option clears all variables but does not close the open files.

load

load with the r option is equivalent to the command run exp$,K. Either
these commands can be used inside programs to allow program chaining

of

— one

program

calling another, etc.

Example
L0AD"PR0G1/BAS:2"
Clears resident basic program and loads progi/bas from Drive 2; returns to

basic

command mode.

am

wltt

Resideii

a

\u,i''if

r

Proi

MERGE eXBS
exp $

is

fiif'-

specification for

MJi

«

r
I

I

if,

e.g.,

^rograu

sawed witi the a option.

—

merge is similar to load
except that the resident program is not erased
the new program exp$ is loaded. Instead, the new program is merged into

before
the

resident program.

That

program

exp$ will simply be inserted into the resident program
numbers in exp$ coincide with line numbers in the
resident program, the resident lines will be replaced by those from exp$.
is,

lines in

in sequential order. If line

119

MODEL

TRS-80

ill

DISK SYSTEM

Program on Disk

Program

10

+
90

in

Ram

Merged Program

10

10

20

20

30

30

40

40

50

50

60

60

70

70

90

in

R

90

j

100

100

110

110

120

120

Sample Use
Save

program

this

in ascii format.

1000 REM
SUBROUTINE TO BAY HELLO
1010 PRINT "HELLO!"
1020 RETURN
.

Type NEW

(ENTER)

100 CLB
110 PRINT
120 PRINT
,130 FOR 1 =
140 GOSUB
150 PRINT
160 END

Now

,

,

type

,

then type in this program.

"LET'S CALL THE SUBROUTINE
,"
"DIALING NOW
1
TO 1000
NEXT
1000
"BACK FROM SUBROUTINE."
,

,"

.

,

;

MERGE

"file" using the file

name given

to the first

file.

List the program.

99

[6 £ 1

Load and Execute a Program from Disk

run

ft7e[.Rl

file is

the

name

constant

*tJ

is

a basic program

used,

basic to leave

the program

120

it

open

Is

run.

file.

II

,$

must be enclosed
files

open.

If

n

m

dnng

expression.

quotes.) The

,r

(If

a string

option causes

omitted, open files are closed before

Then run

it.

This

command

loads and executes a basic program stored on disk.

It

may be

used inside a program to allow chaining (one program calling another).

Examples
RUN "PROG"
Loads and executes prog

(all

open

files

are closed

first).

A$="NEWPRGG"
RUN A$

R

>

Loads and executes newprog

iave

open

remain open).

files

rrogn

save

file [,a]

tile is

the
(If

name

of a basic

a string constant

a cause:, the

This

(all

file

to

program
1?

ised,

be stored

In

file.
ii

If

is

must be sncBosed

asm

ra

ffier

in

in

quotes

than compresses! format.

command

program

a string expression.

lets you save your basic programs on
compressed or ascii format.

disk.

You can save

the

Using compressed format takes up less disk space and is faster during both
saves and loads. Using the ASCII option makes it possible to do certain things
that cannot be done with compressed format basic files.
For example:
8

The merge command

\A
r

V
requires that the disk

file

be

/

vr

in ascii form.
(

Programs which read in other programs
data programs be stored in ascii.
•

The trsdos command append

as data will typically require that the

also requires that disk files be in

/

Jp

x

asch form.

121

\

TRS-80

MODEL

ISi

DISK SYSTEi

Examples
SAUE"FILE1/BAS. J0HN0D0E:3"
saves the resident basic program in compressed format with the
extension /bas, password johnqdoe; the file is placed on Drive

SAVE"MATHPAK/T>!T"

file

name mathpak/txt, on

first nonwrite-protected diskette.

122

filei

.A

saves the resident program in ascii form, using the

Upon completion

name

:3.

of a save, basic returns in the

command mode.

the

,

^m^mmmmmmmsm

>

r ^. Access
1

<

This section

divided into four parts:

is

and assigning buffers

1

Creating

2.

Statements and functions

3.

Sequential

4.

Random

files

i/o

i/o

your

— open and close

techniques

techniques

experience with disk

file access, you should concentrate on
skimming through part 2 to get a general idea of
how the functions and statements work. Later you can go back to part 2 and
learn the details of statement and function syntax.

If this is

parts

1

,

3

and

first

4, perhaps just

Creating Fies and Assigning Buffers
During the
files?

initialization dialog,

The number you type

you type

number

in a

in tells basic

how many

in response to

how many

buffers to create to handle

your disk accesses (reads and writes).

Each buffer

is

given a number from

HOW MANY FILES? 3V

1

to 15. If

you

type:

(MM)

basic sets aside 3 buffers, numbered 1,2,3.

You can think of a buffer as a waiting area that data must pass through on the
way to and from the disk file. When you want to access a particular file, you
must tell basic which buffer to use in accessing that file. You must also tell
basic what kind of access you want

random

input/output.

All this

is

done with

the

—

sequential output, sequential input, or

open statement, and "undone" with

the

close

statement.

OPEN
Dpd bi a Fie

qpem made, buffer,

modie

is

i

a

its

ii

Sepi
ii

record lengih

file

ig

i

icpression contain!

itia

will

impmi sta

rii

ii

i

i

*

one

of

a! the first

i

the toitowii g:

ee§ rd

If

She

lite is

in

i'

hi

*
i

f>

be sm&M'L

mmm
123

.feaSfeel

'

;

Sequential oytput starting at the

o

found,

it

record.

found,

it

will

modeM

a consta

'

it,

the file
i

is

must be enclosed

?!

is

file is

a string expression containing the
it

n smi-lengii

must be enclosed
is

not found,

in

in

:

>5

II

the

file is

file

the

it

will

be created.

coois be

poles,

specification.

is

This statement
details
If file

on

Files?).

same as 256.

record-length

used with Random access

lets

you create a

access, see

file

If

file,

a

vab-iabcc

to

If

a constant

2§§ specifying the

This option

omitted, 256

is

is

is

write data into

may

only be used

if

(How

used, record-length

it,

update

it,

and read

it.

For

later in this section.

specified, basic will search for a matching

master drive (usually Drive

file,

If

starting with the

0).

Examples
OPEN "0"

i

1

"DATAFILE"

>

Opens datafile (creates it if it doesn't already exist) for sequential output.
Output will be done through buffer #1 Records will be 256 bytes long. Since
.

the
If

"o" mode

"e"

is

is

specified, output will start at the

used instead of "o", output

'PAYROLL/A:!"

OPEN

»

first

will start at the

record in the

end of the

file.

file.

G4

Opens/creates payroll/a for random input/output. Access will be through
(if basic was initialized for variable-

buffer #2. Records will be 64 bytes long

length records).

BUFFER

=

3:

&€lo\\X>

FILE*

=

"DATA"

i.e.k)QTO

RECLN

=

128

Li

stcxoe.

OPEN "R"» BUFFER. FILE$» RECL
Opens/creates

data

for

random

Records will be 128 bytes long
records).

124

input/output. Access will be through buffer
( if

as a<5o vC

logical

includes a drive specification/ basic will use only the specified drive.

no drive

is

only.

Methods of Access

basic was

/

be used.

is to

rariable-lengfh records were requested during initialization

Many

not

quotes.

& numeric expression from

record length.

not

file is

file, if

a numeric expression specifying which buffer

buffer

used,

the

be created.

Randominpui/output,

r

IS

will -be created.

(Extend) Sequential output starting at end of

e

IS

first

initialized for variable-length

#3.

P

.j

,i$

**wsi
'Ipglppb
^

^KfflP
^

:J[_ii^Bt
>'iJllilS$liSfifii

IBifP?

Close Access to the Fie

close [nmexp
/i.T/exp

[,

nmexp.

files will

If

command

.] ]

has a value from

(assigned

This

,

when

1 to 15,

the

file

and refers

was opened).

to the file's buffer
If

nmexp

I

s

number

unified, all

§p@i

be closed.

terminates access to a

nmexp has not been assigned

file

through the specified buffer(s).

in a previous

open statement, then

close nmexp
has no effect.

Examples
CLOSE

1

,2,8

Terminates the file assignments to buffers 1, 2 and
assigned to other files with open statements.

8.

These buffers can now be

CLOSE FIRST'Z + COUNT/f.
Terminates the file assignment to the buffer specified by the
(first% + COUNT%).

sum

Do

not remove a diskette which contains a file opened for writing (mode — O,
E, or R). First close the file. This is because the last 256 bytes of data may not
have been written to disk yet. Closing the file will write the data, if it hasn't
already been written.

Any

modification to the resident program (new, editing, load, merge, etc.)

will cause

open

files to

be closed.

125

30DEL

DISK SYST1

111

INPUT#
Seep

]

tial

e

2

>ii

from Disk

ihput# nmexp, !/ar[,rar.

J

where /fme^p specifies
sot

is

the variable

a sequential input file buffer, nmeifi=t,2,. ,,11.

name

to contain the data

This statement inputs data from a disk
is,

when

the

file is first

Each time data

is

beginning of the

file.

opened, a pointer

ffroj-*

The data

is set

is

the

file.

input sequentially. That

to the beginning of the

file.

To start over reading from the
and re-open it.

input, the pointer advances.
file,

you must close

the

file

—

whether a single
input# doesn't care how the data was placed on the disk
print# statement put it there, or whether it required 10 different print#
statements. What matters to input# are the positions of the terminating
characters and the eof marker.

To input# data successfully from disk, you need to know ahead of time what
the format of the data is. Here is a description of how input# interprets the
various characters

When
first

it

when reading

encounters

data.

inputting data into a variable, basic ignores leading blanks;

non-blank character

is

encountered, basic assumes

it

when

the

has encountered the

beginning of the data item.

The data item ends when a terminating character is encountered or when
terminating condition occurs. The particular terminating characters vary,
depending on whether basic

is

a

inputting to a numeric or string variable.

Special Note
Here's an important exception to keep in mind in reading the following material.

When

OTTER) (a carriage return)

is

not taken as a terminator. Instead,
variable) or

is

preceded by
it

becomes a

&

(a line feed), the

part of the data item (string

©

This exception applies to

126

is

simply ignored (numeric variable).

character from the keyboard, press the down-arrow
(To enter the
To enter the OTTER) character, press OTTER) .)

terminator.

OTTER)

all

cases noted below where OTTER)

is

character.

said to be a

IL#i^if\

Suppose the data image on disk

1.234 -33 27

is

(ElTEfD

[ENTER) denotes a carriage-return character (ascii

Then

PMQly

code decimal

13).

the statement

INPUT«i

,

A,B»C

or the sequence of statements

INPUT#i

INPUT*!

.A:

»B:

INPUT#1

,C

will assign the values as follows:

A =1.234

B=-33
C = 27
This works because blanks and (EMTER) serve as terminators for input to numeric
variables. The blank before 1.234 is a "leading blank," therefore it is ignored.
The blank after 1.234 is a terminator; therefore basic starts inputting the second
variable at the

-

character, inputs the

number -33, and

blanks as terminators. The third input begins

at the

takes the next two
2 and ends with the 7.

String Input

When
the

reading data into a string variable, input ignores all leading blanks;
non-blank character is taken as the beginning of the data item.

first

If this first

character

a quoted string:

The

is

a double-quote ("), then input will evaluate the data as

will read in all subsequent characters

up to the next doubleblanks, and (ENTER characters will be included in the string.
quotes themselves do not become a part of the string.

quote.

it

Commas,

If the first character

)

of the string item

is

evaluate the data as an unquoted string:

up

to the first

comma,

or (ENTER)

.

If

not a double-quote, then input will
will read in all subsequent characters

it

double-quotes are encountered, they will be

included in the string.

For example,

if

the data

on disk

PECOS, TEXAS "GOOD
Then

is:

MELONS"

the statement

INPUT*!

i

A$ ,B$ ,C$

127

would assign values

as follows:

A$ = PECOS

B$= TEXAS "GOOD MELONS"
C$ = null
If a

string

comma

is

get the value,

inserted in the data

image before the

first

double quote, c$ will

good melons.

These are very simple examples just to give you an idea of how input works.
different terminators,
However, there are many other ways to input data

—

different target variable types, etc.

Rather than taking a shotgun approach and trying to cover them all, we'll give a
generalized description of how input works and what the terminating characters
and conditions are, and then provide several examples.

basic encounters a terminating character, it scans ahead to see how many
more terminating characters it can include with the first terminator. This ensures
that basic will begin looking for the next data item at the correct place.

When

The

below defines the various terminating

list

sets

input#

will look for.

try to take-in the largest set possible.

always

Numeric-input terminator

sets

file encountered
255th data character encountered

end of

(comma)

,

(Ml

©

(ESTER)
[

.

.

.] [

(ENTER)

[

.

.

.] [

(ENTER)

©
]

1

Quoted-string terminator sets
end of file encountered
255th data character encountered
" (double quote)

"[
"
"

[

•••][,]
.][ (ENTER)!
.

.

[

.

.

.nun©©]

Unquoted-string terminator

sets

end of file encountered
255 th data character encountered
'

(ENTER)

r©1

Figure 13 describes

wmm
128

how input#

assigns data to a variable.

It

will

iaHHnHnB9Bfnsi

_±_

WB9BSH

lifci

mfflEnB?

_y
PUT

EXAMINE NEXT

IT

INTO

EXAMINE NEXT
CHARACTER

TEMPORARY
SAVE AREA

CHARACTER

4T
PICKUP THE

IGNORE

IT

£

TERMINATOR
SET

4L
GET DATA FROM

EVALUATE

TEMPORARY

ASSIGN TO
IT

""?"

VARIABLE

SAVE AREA

Figure 13. Input process.

The following

table

shows how various data images

will

be read-in by the

statement:

INPUTsl »A,B»C

Ek.#

Values

Image on disk

assignee!

123.45

[EWTEffi

3©dHH)

4

^l

8.2E4

A= 123.45

7000 (EWTlER)

HWTER1 5 (ENTER) AlZeof

B = 82000
C = 7000
A = 34
B=5

C=
t

».2,3»4

A=1

(INTER)

B=
C=2
l

>3

»

A=1

eof

B=3
C=
(eof
In

=

end of

file):

Example 2 above, why does

reaches the end of

"A12." This

is

eof error

file, it

variable c get the value 0?

When

the input

terminates that last data item, which then contains

evaluated by a routine just like the basic val function

returns a zero since the

first

character of

"A12"

is

— which

a non-numeric.

t.^iV'V.;'^

129

MODEL

IS-80

In

Example

3,

11!

when input# goes looking

USE

SYSTEM

for the second data item,

it

immediately encounters a terminator (the comma); therefore, variable

B

is

given

the value zero.

The following

table

shows how various data images on disk

will

be read by the

statement:

INPUT#1 »A$.B$
Values assigned

Imag e on disk
'ROBERTS J "ROBERTS
.

.

ROBERTS. J.

»M

,

N

ROBERTS. M.N.

t

A$:ROBERTS,J.
B$:ROBERTS,M.N.

eof

(ENTER)

A$:ROBERTS
B$:J.

THE WORD "QUO" .12345,789

(MM

A$:THE

WORD "QUO

,:

B$: 12345. 789

BYTE©

(ENTER)

A$:BYTE©(HTiB)

UNIT OF MEMORY eof

UNIT OF

MEMORY

B$:nu)l (eof error)

an unquoted string, therefore, the doublequotes are not terminators, and become part of AS.

In

Example

3, the first data

item

In

Example

4, the (EiTER)

preceded by an

the

first string;

both

&

is

is

&, therefore

and fEMTER are included
)

it

does not terminate

in a$.

LINE INPUT#
Read a Line

line

of Text

from Disk

mpin#nmes[fi,vat$

where nmexp specifies a sequential output
var$

is

the variable

name

file buffer,

nmexp =1,2,... ,15.

to contain the string data.

"line" of string
Similar to line input from keyboard, this statement reads a
Ascn-format basic
data into var$. This is useful when you want to read an
program file as data, or when you want to read in data without following the
usual restrictions regarding leading characters and terminators.

130

DISK BASIC

m

mm

line input (or lineinput
character up

—

the space

an (ENTER) character which

1

2. the

end of

3. the

255th data character

pairs

from the

first

is

not preceded by

&

(this

255 character

included in the string)

—

quotes,

is

commas, leading

blanks,

©

(

ENTER)

are included in the string.

For example,
10

optional) reads everything

file

Other characters encountered

—

is

to:

if

the data looks like:

CLEAR 500

20 OPEN" I"

»1

(ENTER)

*"PR0G" (EJUS)

then the statement

LINEINPUTttl ,A$
could be used repetitively to read each program

line,

one

line at a time.

PEINT#
5s

fltin

^

i

i

Wn

mm#nmexp, [using

its

i

d

F

is

is

.

.]

a sequential output file buffer,

a delimiter placed ijetween every two expressions to be PRimed to disk;

is

comma

can be used (semi-colon

file

is

preferable).

the expression to he evaluated and written to disk.

This statement writes data sequentially to the specified
a

nmexp= 1,2, ...,15.

a sequence of field specifiers used with the using option.

either a semi-colon or

exp

Fife

formats;] exp[p exp.

where nmexp specifies
formats

Di k

for sequential output, a pointer

is set

to the

file.

When you

beginning of the

file,

first

open

therefore

your first print# places data at the beginning of the file. At the end of each
print# operation, the pointer advances, so the values are written in sequence.

131

Pi
'H TRS°80 MODEL

US

DiSK SYSTEM

A print#

statement creates a disk image similar to what a print to display
on the screen. Remember this, and you'll be able to set up your print#
correctly for access by one or more input statements.

creates
list

print# does not compress the data before writing
coded image of the data.
For example,

PRINT#1

A=

if

it

to disk;

it

writes an ascii-

123.45

»A

will write a nine-byte character

123.45

sequence onto disk:

(ENTER)

in the print list is very important. Unquoted commas and semicolons have the same effect as they do in regular print to display statements.

The punctuation
For example,

if

A=

2300

and b

= 1.303,

then

PRINT#1 »A»B
places the data on disk as

1,303

2300

(HUB)

The comma between A and b in the print# list causes 10 extra spaces in the
disk file. Generally you wouldn't want to use up disk space this way, so you
should use semi-colons instead of commas.
PRINT*! »A!B
writes the data as:

1.303

2300

(ENTER)

print# with numeric data

is

quite straightforward

—

just

remember

to separate

the items with semi-colons.

print# with

string data requires

more

care, primarily because

you have

to insert

delimiters so the data can be read back correctly. In particular, you must

separate string items with explicit delimiters

if

you want

distinct strings.

For example, suppose:

A*="J0HN

0.

DOE" andB*="100-01-001"

Then:

PRINTbI

>

A*»B*

would produce

this

image on

JOHN 0. DOE100-01-001

disk:

(ENTER)

which could not be input back into two

The

132

statement:

variables.

to

input# them

as

ISK BASIC

www
PRINTttl

A$5" »"5B*

.

would produce:

JOHN 0, DOE. 100-01-001
which could be input# back
This method
(ENTER)

—

adequate

is

if

into

two

variables.

the string data contains no delimiters

— commas or

characters. But if the data does contain delimiters or leading blanks

you don't want to ignore, then you must supply explicit quotes to be written
along with the data. For example, suppose A$ = "DOE
JOHN 0." and B$ = " 100

that

.

-01-001"
If

you use

PRINT*
the disk

.A$i" »"SB$

image

will be:

DOE. JOHN 0, .100-01-001

When you

try to input this

(ENTER)

with a statement like

INPUT#2.A$.B$
A$ will get the value doe, and b$ will get john q.
doe in the disk image.

To write

this data so that

it

can be input

correctly,

— because of

the

comma

you must use

the

chrs

function to insert explicit double quotes into the disk image. Since 34

is

after

the

decimal ascii code for double quotes, use chr$(34) as follows:

PRINT*1 »CHR$(34) iA$!CHR$(34) !B$
this

produces the disk image

"DOE. JOHN Q, "100-01-001

CENTER)

which can be read with a simple

INPUT«2.A$B$
Note: You can also use the chrs function to insert other delimiters and control
codes into the file, for example:
CHRS(iO)

©

chr$(13)

carriage return ((ENTJR)character)

chr$( n ) or chr$( 1 2)

line-printer top-of-form

USING

Line Feed

Option

This option makes

it

easy to write

files in

a carefully controlled format.

For example, suppose:

A$="LUDWIG"

133

IMP"

!S-80

•

;•-•;-

;

"

1
"

MODEL

DISK SYSTEM

111

B*="VAN"
C$="BEETHOMEN"
Then

the statement

PRINT«i tUSING"!
would write

L.U.BEET

,

!,

the data in
<

(In this case,

1

Z" 5A*5B*5Ct

nickname form:

ENTER)

we

didn't want to add any explicit delimiters.) See the print using

description in the level

h basic Reference Manual

for a complete explanation of

the field-specifiers.

Random Access Statements

FIELD
Organize a

field

Random File-Buffer into Fields

nmexp,nmexp1 Asvart$[,nmexp2 as var2$.

nmsxp

specifies a

nmsKfi

random access

speslfiss the length of the

var1$ defines a variable

name

mr,exB2 specifies the length
var2$ defines a variable
.

.

.

Mote: The

fife buffer,

.]

w/nejr/?=1,2,...,15.

first field.

for the first field.

of the

name

.

second

for the

field.

second

field.

Subsequent nmexpks, var$ pairs define other

sum

of all the field-Iangths

fields in the buffer.

must not exceed the record length, and

should equal the record length.

Before FiELDing a buffer, you must use an open statement to assign that buffer
to a particular disk file (you must use random access mode). Then use the field
statement to organize a random file buffer so that you can pass data from basic
to disk storage

and vice-versa.

Each random file buffer has up to 256 bytes which can store data for transfer
from disk storage to basic or from basic to disk. (When variable-length files are
used, maximum may be from 1 to 256.) However, you need a way to access this

134

SsiC

buffer from basic so that you can either read the data

data in

The field statement provides

it.

You may use

the

held

means of

the

it

contains or place

new

access.

statement any number of times to "re-organize" a

file

buffer. FiELDing a buffer does not clear the contents of the buffer; only the

means of accessing the buffer (the field names) are changed. Furthermore, two
or more field names can reference the same area of the buffer.

Examples
FIELD

1

>

128 AS A$

This statement

tells

123 AS B$

,

basic to assign the

first

128 bytes of the buffer to the string

you now print a$ and b$, you
value would be meaningless
read a 256-byte record from disk.

variable a$ and the remaining 128 bytes to b$. If

Of course,

will see the contents of the buffer.

unless you have used

get

to

—

this

—

both strings and numbers
must be placed into the buffer in
There are three pairs of functions (mki$/cvi,mks$/cvs,mkd$/cvd)
for converting numbers to strings and vice- versa. See "Functions" below.

Note: All data
string form.

FIELD 3. IB AS NH$
The

first

25 AS AD$

,

»

10 AS

CY$

,

AS ST$

2

H

AS ZP$

name nm$; the next 25,
next 7, zp$. The remaining 196

16 bytes of buffer 3 are assigned the buffer

ads; the next 10, cy$; the next 2, st$ and the
bytes of the buffer are not fielded

at all.

More on field names
Field names, like nms,ad$,cy$,st$, and zp$, are not string variables in the

ordinary sense.

They do not consume

Instead, they point to the buffer field

statement. That's

100 FIELD

why you

the string space available to basic.

which you assigned with the field

can use:

>255 AS A$

1

without worrying about whether 255 bytes of string space are available for a$.
If

you use a buffer

statement, that

won't be able

field

name

name on

will

the left side of an ordinary assignment

no longer point

to the buffer field; therefore,

to access that field using the previous field

you

name.

For example,
A$ = B$
nullifies the effect

of the field statement above (line 100).

During random input, the get statement places data into the 255-byte buffer,
where it can be accessed using the field names assigned to that buffer. During
random output, lset and rset place data into the buffer, so you can then put
the buffer contents into a disk

file.

135

Is
JSP

RS-80 MODEL

SiE

DISK SYSTEM

Often you'll want to use a dummy variable in a held statement to "pass
over" a portion of the buffer and start fielding it somewhere in the middle.

For example:

FIELD

It

16 AS

FIELD

1»

128 AS DUMMY$

In the second

CLIENT$(1). 112 AS HIST$(1)

held

1G AS

>

statement,

dummys

CLIENT$(2)j 112 AS HIST$(2)
serves to

client$(2) to position 129. In this manner,

defined on buffer

number

the buffer or retrieve

The

now

buffer

it

1

.

We

from the

looks like

two

move

the starting position of

identical

won't actually use

"subrecords" are

dummy$

to place data into

buffer.

this:

16

112

16

112

CL$

HIST$

CL$

HISTS

(D

(1)

(2)

(2)

>UMMY$

Read a Record from Disk— Random Access

get nmexp1[,ttmexp2\

ttmespl specifies

aim xfk &c «.

:

;

pr

\

random access >ib

v&im tecsn h &b

buffer,

i>i

\k

nmexi

fi! 5

if s

h

1

= 1,2, ...,15.
tied

this

1

1

-i^l

reeord will be read.

This statement gets a data record from a disk file and places it in the specified
buffer. Before GETting data from a file, you must open the file and assign a
buffer to

it.

That

is,

a statement like:

open "R" ,nmexpl ,filespec
is

required before the statement:

get nmexpl ,nmexp2
get

tells

buffer. If

136

basic to read record nmexpl from the file and place it into the nmexpl
you omit the record number in get, basic will read the current record.

OS
^^^^^^^^^^^^^^^^^^^^^^J

The "current record" is the record whose number is one higher than that of the
last record accessed. The first time you access a file via a particular buffer, the
current record

is

set equal to

1

For example:

Program statement
1000

Effect

Open name/bas

OPEN"R",l,"NAME/BAS"

using buffer
1010

FIELD

1020

GET

GET

1

get record

GET

1050
If

GET

into buffer

1

get record 30

into buffer

1

get record 25

into buffer

1

get record 26

into buffer

1

BUFFER

1,25

1046 REM... ACCESS

1

BUFFER

,30

1035 REM... ACCESS

1040

random access

Structure buffer

1,...

1

1025 REM... ACCESS

1030

for

1

BUFFER

1

you are using variable-length records (not
end of file will produce an error.

fixed-length), an attempt to

get

past the

If you are using fixed-length records, the same attempt will return a null record
and no error will occur. To prevent this from occurring, you can use the lof

function to determine the

number of

Write a Record to

the highest

numbered record.

Disk— Random Access

put nmexp1[,nmexp2\

nmexpl

specifies a

nmexp2 specifies
want

random access

the record

to write.

If

file buffer,

number

nmexp2 is

in

the

nmexp=1,2

file,

nmexp2i$

15.

the record you

omitted, the current record

number

is

assumed.

This statement moves data from a

Before PUTting data in a
1

.

open the
be

file,

file,

file's

buffer into a specified place in the

file.

you must:

thereby assigning a buffer and defining the access

mode (must

r);

137

"«n asms/am

I.

_ jggg

MODEL

TRS-80

8

81

DISK SYSTEM

^&m*^
2.

field the buffer, so you can

3.

place data into the buffer with lset and rset statements.

When

basic encounters the statement:

put nmexp ,nmexp2
it

does the following:

8

Gets the information needed to access the disk

•

Checks the access mode

Acquires more disk space for the
indicated
•

file

for this buffer (must be r)
file if

necessary to accommodate the record

by nmexp2

Copies the buffer contents into the specified record of the disk

Updates the current record number

to equal

nmexp2

file

+

The "current record" is the record whose number is one higher than the last
record accessed. The first time you access a file via a particular buffer, the
current record

is

set equal to

1

record number you put is higher than the end-of-file record number, then
nmexp2 becomes the new end-of-file record number.
If the

LSET and RSET
Place Data in a F

lset var$

=

var$

}

~

edom Bel

r Field

exp$ and rset var$= expS

is

a field

name.

exp$ contains the data

to

be placed

in

the buffer field

These two statements let you place character-string data
set up by a held statement.

named by

var$.

into fields previously

For example, suppose nm$ and ad$ have been defined as field names for a
random file buffer. nm$ has a length of 18 characters, and ad$ has a length of
25 characters.

Now we

want

to place the following information into the buffer fields so

be written to disk:

138

it

can

:-;|lif|li|flli

DISK

address:
is

SIC

JIM CRICKET, JR.
2000 EAST PECAN ST,

name:

This

::<-

accomplished with the two statements:

LSET NM$="JIM CRICKET, JR.

"

LSET AD*="2000 EAST PECAN ST.

"

This puts the data in the buffer as follows:

JIM CRICKET .JR.

2000 EAST PECAN ST.

NM$
Note
If

AB$

that filler spaces

we had used rset

been placed on the

were placed

to the right of the data strings in both cases.

instead of lset statements, the

left.

This

the only difference

is

filler spaces would have
between lset and rset.

For example:

RSET NH$="JIM CRICKET »JR. "
RSET AD$="2000 EAST PECAN ST.

"

places data in the fields as follows:

JIM CRICKET, JR,

2000 EAST PECAN ST.

NM$
If

a string item

is

AD$
too large to

truncated on the right. That

fit

is,

in the specified buffer field,

it is

always

the extra characters on the right are ignored.

CVD, CVI and CVS
Restore String to Numeric

Form

£\io(ezp$)

expS defines an

eigiit-cliaraeier string;

expS

is

buffer field containing a numeric string.

function call error occurs;

if

typically the
If

name

im(expS)B, onty the

first

of a

illegal

eight

characters are used.

cw(exp$)

expS defines a two-character

string;

field containing a

numeric

call error occurs;

if

exp$is

string.

If

typically the

name

of a buffer

im(tsxp$)<2, an illegal function

LEH(exp$)>2, only the

first

two characters are

used.

tmmmsm

"-.„.:.—

:

ItillllillMllllli

^
139

TRS-80

MODEL

ill

DISK SYSTEI

cvs(exp$)

exp$ defines a four-character string; exp$ is typically the name of a buffer
field containing a numeric string. If im(exp$)<4, an illegal function
call error occurs;

if

im(exp$)>4, only the

first

four characters are

used.

These functions

let

you

restore data to numeric

form

after

Typically the data has been read by a get statement, and

access

The

file

it is

is

read from disk.

stored in a random-

buffer.

functions cvd, cvi, and cvs are inverses of mkds, mki$, and mks$,

respectively.

For example, suppose the name grosspays references an eight-byte field in
a random-access file buffer, and after GETting a record, grosspays contains a
mkds representation of the number 13123.38.

Then

the statement:

PRINT CVD (GROSSPAYS) -TAXES
prints the result of the difference,

13123.38 -taxes. Whereas the statement:

PRINT GROSSPAY$-TAXES
will

produce a type mismatch

error, since string values

cannot be used in

arithmetic expressions.

Using the same example, the statement

A*=CVD( GROSSPAYS)
assigns the numeric value 13123.38 to the double-precision variable

End-Of-File Detector

tQF(nmexp)
amer.p spaciliss z

140

file buffer,

«jfix/j=1,2,...,15.

A#.

DISK BAS

This function checks to see whether all characters up to the end-of-file marker
have been accessed, so you can avoid input past end errors during sequential
input.

Assuming nmexp specifies an open file, then EOF(nmexp) returns (false) when
eof record has not yet been read, and - 1 (true) when it has been read.

the

Examples
EOF (5) THEN PR I NT "END OF FILE"FILENM$
THEN CLOSE NMZ

IF

IF EOF(NMX)

The following sequence of
array a(

).

When

lines reads

numeric data from data/txt into the
file is read, the eof test in line

the last data character in the

30 "passes," so the program branches out of the disk access loop, preventing
an input past end error from occurring. Also note that the variable I contains
the

5

10

number of elements

input into array a(

).

DIM A(100) 'ASSUMING THIS IS A SAFE VALUE
OPEN "I" ,1
"DATA/TXT"

20
30
40
50
60
70

,

I% =
IF E0F(1) THEN 70
INPUT#1 fA(I%)
IX=IX+1
GOTO 30
REM PROGRAM CONTINUES HERE AFTER DISK

INPUT

LOC
Get Current Record Number

imijlie number)
file

number Is
open

loc

is

used

to

a

numeric expression specifying the buffer for a currentiy-

fife.

determine the current record number, i.e., the number of the
file was opened, loc is only valid after a get.

last

record read since the

Example
PRINT LOC(l)

141

I.fc»!*«lfip

-

~

S-80MODE!

Ill

DISK SYSTEM
i

1310 A$ = "WILLIAM WILSON"
1320 GET It >!; >( = )<+
1330 IF N$ = A$ THEN PRINT "FOUND IN RECORD" LOC(i): CLOSE:
END
1340 GOTO 1320
This
N$
is

is

a portion of a program. Elsewhere the file has been opened and fielded.
a field variable. If N$ matches a$ the record number in which it was found

is

printed.

EMcMDfMfld Record Number

C cH

lof(nmexp)

nmexp specifies

This function

tells

you

in a file. It is useful for

a

random access

buffer /Mne*p=1,2,...,15.

number of the last, i.e. highest numbered, record
both sequential and random access.

the

,

For example, during random access to a pre-existing file, you often need a
way to know when you've read the last valid record, lof provides a way.

lof
lof

is

valid as soon as a previously created

is

not valid until a get

is

file is

opened.

If a file is

extended,

executed.

Examples:
"R" »1 ."UNKNOWN/TXT'
FIELD 1 »255 AS A$
F0RH,= 1 TO L0F(1)
GET 1 til
PRINT A*
NEXT

10 OPEN

20
30
40
50
B0

In line 30, lof(1) specifies the highest record

number

to

be accessed.

Note: If you attempt to get record numbers beyond the end-of-file record, basic
simply fills the buffer with hexadecimal zeros, and no error is generated.

W^^^^^^^^^^M

142

L#roi\

DftOIV

MrattK^
When you want

to

add

100 IX=L0F(1)+1
110 PUT 1,11

MKB$

?

end of a

to the

file,

lof

tells

you where

to start adding:

'HIGHEST EXISTING RECORD
'ADD NEXT RECORD

MKI$, and

MKS$

MK.a$(nmexp)

amexp

if,

ewataafecl as a double-precision

is

evaluated!

numl

er.

mm$(amexp)
nmexfl

excaefis

1P?15>

fractional

amintepi -32761
-amp, an illegal functidk

r

nmexp< M7§B;

«

component

in

nmexp

r

cai

i

error occurs.

II

mnexp

Any

s truncated.

m$&(nmexp)

nmexp

is

evaluated as a single-precision number

These functions change a number to a "string." Actually the byte values which
make up the number are not changed; only one byte, the internal data-type
specifier, is changed, so that numeric data can be placed in a string variable.
That

is:

mkd$

returns an eight-byte string.
mki$ returns a two-byte string.

mks$

returns a four-byte string.

Examples
LSET TALLY$=MKI*(IZ)
Field

name tallys would now

contain a two-byte representation of the

integer i%.

A$=MKI$(8/I)

143

TRS- 80

MODEL

Sit

DISK SYSTEM

a$ becomes a two-byte representation of the integer portion of 8/1. Any
fractional portion is ignored. Note that A$ in this case is a normal string
variable, not a buffer- field

name.

(a non-standard file extension) has been opened for
access using buffer 2, and the buffer has been FiELDed as follows:

Suppose baseball/bat

random

NM$

field:

16

length:

YRS$
2

AVG$
4

AB$
4

HR$
2

ERNINGS
4

intended to hold a character string; avg$, ab$ and ernings, converted
single-precision values; yrss and hrs, converted integers.

nm$

is

Suppose we want

to write the following data record:

slow learner played 38

years; lifetime batting average .123;

career homeruns, 11; at bats, 32768;..., earnings

Then we'd use
1000
1010
1020
1030
1040
1050

LBET
LSET
LSET
LSET
LSET
LSET

13.75.

the make-string functions as follows:

NM*="SL0W LEARNER"
YRS$=MKI$(3B)
AVG*=MKS*(.123)
HR*=MKI*( 11
AB$=MKS$(327G8)
ERNING*=MKS$<-13,75)

After this sequence, you can write
the put statement. When you read
to

-

slow learner's

information to disk with

back from disk with get, you will need
string
to numeric form, using cvi and cvs
from
data
restore the numeric

functions.

144

it

Methods of Access
Disk basic provides two means of
•

8

file;

access:

—

in which you start reading or writing data at the beginning of
subsequent reads or writes are done at following positions in the file.

Sequential
a

file

Random

—

in

which you

(Random access

is

Sequential access

is

start

reading or writing

at

any record you specify.

also called direct access.)

is, the number of characters read or
usually determined by delimiters in the data. Random
access is record-oriented; that is, data is always read or written in fixed-length
blocks called records.

stream-oriented; that

written can vary, and

is

To do any input/output to a disk file, you must first open the
open the file, you specify what kind of access you want:
8
8

o
1

file.

When you

for sequential output

for sequential input

random

•

R

8

e (Extend) for sequential output starting

for

You

input/output

also assign a

can be from

file

end of

at the

buffer for basic to use during

file.

file

accesses. This

number

must not exceed the number of concurrent files you
requested when you started basic from trsdos. For example, if you started
basic with 3 files, you can use buffer numbers 1, 2, and 3. Once you assign a
buffer number to a file, you cannot assign that number to another file until you
Close the

1

to 15, but

first file.

Examples
OPEN "0"

>

1

>

"TEST"

Creates a sequential output file named test on the first available drive; if test
already exists, its previous contents are lost. Buffer 1 will be used for this file.

OPEN "I"

.

Opens test

OPEN "R"

,

Opens test

2,

"TEST"

for sequential input, using buffer 2.

It

"TEST"

for direct access, using buffer

created on the

first

1

.

If

test does not

available drive. Since record length

is

exist,

it

will

be

not specified, 256-byte

records will be used.

OPEN "R"

Same

»

1

,

"TEST"

»

40

as preceding example, but 40-byte records will be used.

OPEN "E"

,

1

,

"TEST"

Opens test sequentially

for write

and positions

to eof.

145

Sequential Access
way

to store data in and retrieve it from a file. It is ideal for
without
wasting space between data items. You read the
storing free-form data
items back in the same order in which they were written.

This

is

the simplest

There are several important points

to

keep

in

mind.

You must start writing at the beginning of the file. If the data you
is somewhere inside, you have to read your way up to it.

1

are seeking

2.

Each time you Open a file for sequential output, the file's previous contents
are lost, unless you use "E" instead of "O" for the mode.

3.

To update (change) a sequential
data to a

4.

new

output

file,

read in the

file

and write out the updated

file.

Data written sequentially usually includes delimiters (markers) to signify
where each data item begins and ends. To read a file sequentially, you must
know ahead of time the format of the data. For example: Does the file consist
of lines of text terminated with carriage returns? Does it consist of numbers
separated by blank spaces? Does it consist of alternating text and numeric
information?

5.

Sequential

files are

always written as ASCII-coded

text,

one byte

for

each

character of data. For example, the number:

1.2345
requires 8 bytes of disk storage, including the leading and trailing blanks that
are supplied.

JOHNSON

The

text string:

ROBERT

t

requires 15 bytes of disk storage.
6.

Sequential

files are

always written with a record length of 256.

Sequential Output:
Suppose we want
English unit

An Example

to store a table of English-to-metric conversion constants:

Metric equivalent

1

inch

1

mile

1

acre

2.54001 centimeters
1 .60935 kilometers
4046.86 sq. meters

1

cubic inch

0.01638716

1

U.S. gallon

1

liquid

3.785 liters
0.9463 liter

1

lb (avoir)

146

quart

liter

0.45359 kilogram

ASIC

First

we

decide what the data image

is

going to be. Let's say

we want

it

;.

to look

like this:

english unit } metric unit, factor (ENTER)

For example, the stored data would

IN->CM» 2,54001

start out:

CENTER)

The following program

will create

such a data

file.

Note: x'OD' represents a carriage return.
"0"

(1 ,"METRIC/TXT"
FOR IX =1 TO 7
READ UNITS FACTR
PRINT#1
UNIT$! " >"
FACTR
NEXT
CLOSE
DATA IN->CM> 2,54001, MI->KM» 1.G0935, ACRE->SQ.KMt
404G.8G E-G
80 DATA CU,IN->LTR> 1.G38716E-2, GAL->LTR
3,785
90 DATA LIQ,QT->LTR» 0,9463, LB->KG» 0,45359

10 OPEN

20
30
40
50
60
70

»

*

5

>

file named metric/txt, and assigns buffer 1 for sequential
The extension /txt is used because sequential output always

Line 10 creates a disk
output to that

file.

stores the data as

Ascn-coded

text.

Note: If metric/txt already exists, line 10 will cause all its data to be lost.
Here's why: Whenever a file is opened for sequential output, the end-of-file
(eof) is set to the beginning of the file. In effect, trsdos "forgets" that
anything has ever been written beyond this point. To avoid this, you could use E
instead of o in line 10.
Line 40 prints the current contents of units and factr to the file. Since the
sJJing items do not contain delimiters, it is not necessary to print explicit quotes
around them. The explicit comma is sufficient.

Line 60 closes the file. The eof is at the end of the last data item, i.e. 0.45359,
so that later, during input, basic will know when it has read all the data.
,

The following program reads the data from metric/txt
arrays, then asks you to enter a conversion problem.
CLEAR 500
UNIT$(9)
FACTRO)
20 OPEN" I" *1 "METRIC/TXT"

into

two "parallel"

5

10 DIM

t

'allows for up to 10 data pairs

,

12=0
30 IF EOF(l) THEN 70
40 INPUT*!* UNIT$(I2) »FACTR(I2)
25

147

^M^QP^Jll.

18 ^

SYSTEM

IplIllS

n,=n,+i

50

S0 GOTp 30
70 CLOSE
100 CLS:

Conversion factors have been read-in
PRINT TAB(5)"*#* English to Metric Conversions ###"
'

TO 17,-1
110 FOR ITEM?, =
120
PRINT TAB (9) .USING" <##

1

"5 ITEM'/,

1

>

UNIT* (ITEM?,)
NEXT
PRINT @ 704
"Which conversion (0-B)"i
INPUT CHOICE!
INPUT"Enter English quantity" .U
PRINT"The Metric equivalent is" Y*FACTR(CHOICEZ)
INPUT"Press  to continue" iX
PRINT i 704 CHR$(31)
'clear to end of frame
GOTO 140

130
140

i

150
1B0
170
180
190
200

>

Line 20 opens the
the

)

file

for sequential input. Input begins at the beginning of

file.

Line 30 checks to see that the end-of-file record hasn't been reached.
control branches

from the disk input loop

newly acquired

the

to the part of the

program

If

it

has,

that uses

data.

Line 40 reads a value into the string array unit$(

Note

),

and a number

into the

input list parallels the print#
that created the data file (see the section "Sequential Output: An Example").
This parallelism is not required, however. We could just as successfully have
single-precision array factr(

).

that this

list

used:

INPUT*!

40

UNIT$(IX):

,

INPUT*1 »FACTR< 11

How to update a ile
Suppose you want to add more entries into the English-Metric conversion file.
You could simply re-Open the file with mode = e and print# the extra data.
Or, you might want to leave the old file intact and output a new file:
1

Open

the

file

for sequential input

(Mode =

i)

(Mode =

2.

Open another new

3

Input a block of data and update the data as necessary

4.

Output the data to the

5.

Repeat steps 3 and 4

new
6.

file;

file

new

files

for sequential output

o)

file

until all data

then go to step 6

Close both

148

data

has been read, updated, and output to the

Using the line-oriented input, you can write programs that edit other basic
program files: renumber them, change lprints to prints, etc.
as long as these
"target" programs are stored in ascii format.

—

The following program counts
disk

file

the

number of

lines in

any ascii

— format basic

with the extension /txt.

10 CLEAR 300

20 INPUF'WHAT IB THE NAME OF THE PROGRAM"! PROG*
30 IF INSTR(PROG*»"/TXT">=0 THEN 110 'require /TXT extension
40 OPEN" I "
PROG*
1
50 n, =
G0 IF E0F(1) THEN 90
70 I%=IX+1: LINE INPUT#1
TEMP*
80 GOTO G0
90 PRINT PROG*" IB" 11 "LINES LONG,"
100 CLOSE: GOTO 20
110 PRINT "FILEBPEC MUST INCLUDE THE EXTENSION '/TXT'"
120 GOTO 20
i

i

>

For basic programs stored in ascii, each program line ends with a carriage
return character not preceded by a line feed. So the line input in line 70
automatically reads one entire line at a time, into the variable temps. Variable
i% actually does the counting.

To

try out the

program,

first

save any basic program using the A (ascii) option

(See save). Use the extension /txt.

149

MODEL

TRS-80

Random
•

Sii

DISK SYSTEM

access offers several advantages over sequential access:

Instead of having to start reading at the beginning of a

file,

you can read any

record you specify.
•

To update a
write

you don't have

file,

You can

out again.

it

to read in the entire file,

update the data, and

rewrite or add to any record you choose, without

having to go through any of the other records.
•

Random

access

more

is

efficient

—

data takes up less space and

read and

is

written faster.
"

-

Opening a file for
the same buffer.

Random

direct access allows

access provides

you

many powerful

your data. Once you have

set

up the

to write

and read from the

file

via

statements and functions to structure

structure, direct input/output

becomes

quite simple.

The
a

last

little

advantage

listed

above

is

"hard part" of

also the

direct access.

It

takes

extra thought.

For the purposes of direct access, you can think of a disk file as a set of boxes
like a wall of post-office boxes. Just like the post office receptacles, the file
boxes are numbered. We call these boxes "records."

—

You can place data

in

any record, or read the contents of any record, with

statements like:

PUT

1

>5

write buffer- 1 contents to record 5

GET

1

f5

read the contents of record 5 into buffer-

In

Figure 14, we assume a record length of 256.

('256 1
Kbytes/

(ZS6

#6
236
VBYTES
/

#1

)

/256

#7
/

256

\

f

#2

Figure 14. get and put.

150

#8

#9

256

/256

\

Uytes,/ Kbytes/

RECORDS

M^^ii«

f

\

\BYTES/ Ibytes/ Kbytes/

#3
IN

V

256

'

BYTES;

#10
\

BYTES/

#4

i

258
StTE8

#5

DISK FILE

I/O

BUFFERS

IN

RAM

The

buffer

place

must

is

a waiting area for the data. Before writing data to a

in the buffer assigned to the file. After reading data

it

retrieve

As you can

from the

it

you must
you

file,

buffer.

see from the sample put and

and from the disk

file,

from a

in records.

The

get statements above, data is passed to
is determined by an Open

size of each record

statement.

storing Data in a Butter
You must place
the disk

This

is

the entire record into the buffer before putting

its

contents into

file.

accomplished by

dividing the buffer up into fields and naming them,

1)

then 2) placing the string or numeric data into the fields.

For example, suppose we want to store a glossary on disk. Each record
consist of a word followed by its definition. We start with:
100 0PEN"R"»
110 FIELD 1,

Line

1

"GLOSBARY/BAS"
240 AS MEANING*

1*

1G AS WD$»

Line 100 opens a

and gives buffer

file
1

named glossary/bas

direct access to the

wd$

consists of the

meanings

consists of the last

first

it

if

it

doesn't already exist);

1:

16 bytes of the buffer;

240

bytes.

now field-names

wd$ and meanings

are

What makes

names

field

(creates

file.

10 defines two fields onto buffer

memory

will

different?

called the string space. This

Most
is

string variables point to an area in

where the value of the

string is stored.

Field names, on the other hand, point to the buffer area assigned in the field
statement. So, for example, the statement:

10

PRINT WD$i

":"S MEANINGS

displays the contents of the two buffer fields defined above.

These values are meaningless unless we first place data in the buffer, lset, rset
and get can all be used to accomplish this function. We'll start with lset and
rset, which are used in preparation for disk output.

Our

first

entry

is

100 0PEN"R"»
110 FIELD It

the

word

"left-justify" followed

by

It

"GLOSSARY/BAS"

1G

AS WD$, 240 AS MEANING*

its

definition.

120 LSET WD$="LEFT-JUSTIFY"
130 LSET MEANING$="T0 PLACE A VALUE

IN A FIELD FROM LEFT TO
RIGHT? IF THE DATA DOESN'T FILL THE FIELD* BLANKS ARE
ADDED ON THE RIGHT! IF THE DATA IS TOO LONG. THE EXTRA

151

R51-80

HOI

F
'

"l<

li!

M^K

<-V

"-TFSWS

CHARACTERS ON THE RIGHT ARE IGNORED. LSET
JUSTIFY FUNCTION,"
Line 120 left-justifies the value in quotes into the
does the same thing to its quoted string.

Notes rset would place filler-blanks to the
still be on the right.

Now

that the data is in the buffer,

we

left

can write

IB

first field in

A

LEFT-

buffer

1

.

Line 130

of the item. Truncation would

it

to disk

with a simple put

statement:

140 PUT 1
150 CLOSE

.1

This writes the

To read and

first

record into the

print the

first

file

gloss ary/b as.

record in glossary/bas, use the following sequence:

0PEN"R"
It "GLOSSARY/BAS"
FIELD It IB AS WD$ 240 AS HEANING*
GET 1 (1
PRINT WD$: PRINT MEANING$
200 CLOSE
1G0
170
180
190

>

>

Line 160 and 170 are required only because we closed the
it, we could go directly to line 180.

hadn't closed

152

file in line

150. If

we

MB

WSm&Es&mSBBm&l

~'

*•UFA

om Access: A General
rtore
The previous example shows the necessary sequences to read and write using
random access. But it does not demonstrate the primary advantages of this form
of access
in particular, it doesn't show how to update existing files by going

—

directly to the desired record.

The program below, gloss acc/bas, develops the glossary example to show
some of the techniques of random access for file maintenance. But before
looking

at

the program, study this general procedure for creating and

maintaining

files

random

via

access.

See GLOSSACC/BAS,

Step
1.

Open

2. Field

the

Line

110
120
140
145-170

file

the buffer

be updated

3.

Get the record

4.

Display current contents of the record (use

CVD,

CVI,

to

CVS

Number

before displaying numeric

data)
5.

LSET and RSET new values into the fields
(use MKD$, MKI$, MKS$ with numeric data
before setting

6.
7.

8.

it

210-230

into the buffer)

PUT the

updated record
To update another record, continue
Otherwise, go to step 8.
Close the file

240
250-260

at step 3.

270

GLOSSACC/BAS ,,
CLEAR 300
10 OPEN "R"» if "GL0SSARY/BAS"
20 FIELD It IS AS WD*
238 AS MEANING*
2 AS NX*
30 INPUT "WHAT RECORD DO YOU WANT TO ACCESS"! RZ
40 GET 1
HI
45 NX% = CUHNX*)
'SAME LINK TO NEXT ALPHABETICAL ENTR
50 PRINT "WORD
"WD*
"
(30 PRINT "DEF'N
PRINT MEANING*
70 PRINT "NEXT ALPHABETICAL ENTRY: RECORD »:" NXZ
PRINT
80 W* =
INPUT "TYPE NEW WORD < ENTER) OR
ENTER) IF OK'
REM
00 CLS

,

:

>

>

>

:

:

:

'

W$
190 D* =
OK?"

200 INPUT
210 IF W*
220 IF D*

'

PRINT "TYPE NEW DEF'N < ENTER) OR < ENTER) IF
LINE INPUT D$
'TYPE NEW SEQUENCE NUMBER OR -(ENTER) IF OK "
NXZ
""
=
:>
THEN LSET WD*
W$
:> "" THEN LSET MEANING* = D*
'

:

:

i

153

i3j TRS-8 MQDEL

ill

DISK SYSTEM

230 LSET NX* = MKI* (NXX)
240 PUT 1
R7„
2/15 Rl = m TO READ NEXT ALPHA, ENTRY,":
PRINT" OR RECORD #  FOR SPECIFIC ENTRY*
INPUT "
OR
< ENTER) TO QUIT";
Rl
2B0 IF ® TO CONTINUE"?
IF HI <>
THEN 350
CLOSE
END

X

to a

3

two-

Disk

BASIC Error Codes/Messages

51

Field overflow

52
53
54
55
58
62
63
64
65
67
68
69
70

Internal error

Bad

file

number

File not

found

Bad

mode

Disk
Disk

file

i/o error
full

Input past end

Bad record number
Bad file name
Direct statement in

file

Too many files
Disk write-protect
File access

Note: Disk errors cannot be simulated via the error statement.

155

WMWM&ammmmmMmmmm

iMmMi

naex

Page

Subject

14

Library

26
26, 53
24, 27, 60
29, 72
25, 57, 67

Syntax

Abbreviate

APPEND
ASCII

ATTRIB

10,

AUTO
BACKUP

8,

BASIC

17

BASIC*
Baud

91

Buffer

12,62
62
82
29, 31 44, 96
91, 123

BUILD

29,31,45,57

Bits

i,

BKSPC
(BREAK)

,

Byte

i,

Cable (Ribbon)

74
1,2

18, 62,

Cass?

12

CLEAR
CLOCK
CLOSE
CLOAD
CLS
CMD"A"
CMD"B"
CMD"C"
CMD"D"
CMD"E"

31

CMD'T'

CMD"J"
CMD"L"

CMD"0"
CMD"P"
CMD"R"
CMD"S"
CMD'T"
CMD"X"

72
33
125
63
33
93, 95
93, 96
93, 96
93, 97
93, 98
93, 98
93, 99
93, 100

32, 45,

93, 101
93, 102

Entering
of

20
67-89

Utility

CONVERT
COPY

8, 10,

CREATE
CSAVE
CVD,

CVI,

CVS

21

See

DATE

Diskette

37
76
37
93,106
36,

DCB
DEBUG
DEFFN
Definitions

Comments

21-2

Delimiter

22

Filename
Options

21-2

22

DEF USR

93, 108

DIR

25,27,44

Disk BASIC
Abbreviations

95

Instructions
Starting

11,12
11, 91-2

Disk Drive

Oand

1

1,4,

6, 10,

55
1,4
1,4
1,4

34,

3 (External)
Expansion

2,

Installation

Diskette

Care
Data

5
i,

24

Description
Inserting

5,

Labelling

Specifications

29-30
20

68

35
63
139-40

Data Diskette

93, 103

93, 105

25,

34, 50

Notch-protect
Organization

93, 104

Auto

26-66

93, 103

93, 104

CMD"Z"
Commands
Forms

,

Page

Subject

System
DIVIDE

5
7
6
5

74
15

DUAL

24
83
84
31,32,46,57,71
23
47

DUMP

48,54,59

DMULT
DO
Drive Specification

i,

6,

157

TRS-80

MODEL

ill

DISK SYSTEM

Page

Subject
EOF (End-of-file)

45, 75,

1

40-1

ERROR

49

Error

DiskBASIC

TRSDOS
Extents

FIELD

13
155
90
See Technical Information
134-6

File

116, 123, 145

APPEND
COPY
Manipulation
System vs User
Variable Length

26
34
116,118
25

MID$
MKD$, MKI$, MKS$

93, 111

NAME

93,112

FORMAT
FORMS

50

136-7

Granules

50
74
45, 51 74
51,53

Defined
of

,

HELP
HERZ50

71

Hexadecimal

53
94
78
126-30

32, 38, 41 48,
55, 59, 93,
,

INIT

INPUT #

1-3

Installation

93,108

INSTR

32, 61

I/O

75, 77-89

I/O Calls

52,118

KILL

LSET

138-9

53
110,93

LIB

LINE INPUT
LINE INPUT
LIST

#

OPEN
Operation

Password

130-1

Master

Update

PATCH
PAUSE

POSEOF
POSN
Power On/Off

PRINT #

PROT
PURGE
PUT

General Procedure
Techniques

READ
Record Length
Logical Length
Physical

Reset

LOC

141-2

LOF
LPC

142

Location

REWIND

ROM

13

ROUTE
RSET

Memory
Display

38

Map

19

158

RENAME

71

64

38, 59

81
18, 32, 40, 64, 71

RAMDIR
Random File Access

Number

RS-232-C

RUN
SAVE

1

137-8

RAM

11

55,

ii,

10,25,57
25, 58

PUTEXT

Load

Maintenance

131-3

Programming

RELO

12, 54,

27
69
27
27
9, 25
69
27
12,55
56
82
79
4, 30

31,47, 105

Printer

53
118

LOAD

14
93, 94
123,4
4
8, 24, 25,
57, 60, 67,

Protecting

35,

Allocation

Octal

8,9,25,70
49

FREE
GET

User

11

Access
Changing

FILPTR

143-4

NEW

44
22
85

23,

File Specification

MASTER

72
119

91

Filename

11

MEMTEST
MERGE

Notations/Abbreviations

Access

Number

Memory Size?

of

,

73
84

150-4

153
1 50
70
35, 45
26, 35, 45, 76
45, 77
77
59
35, 60
30, 73
4

82
73
47, 61

138-9

62
120
11,121

INDE y

Page

Subject
Save

SETCOM
Sequential File Access
Sequential Input
Sequential Line Input
Sequential Output

77
62
146-149
1 47
149
146

Page

Subject

11

Sector

i

Figures and Tables
A

Diskette

5

Connection of the External Disk Cable
to the

Model

2
3

III

Connection of External Disk Drives
Directory Listing (dir)

Starting

Auto

29

DiskBASIC
System

11

6
7

TRSDOS
Specifications

15

System Diskette

See "Diskette"

Syntax

83
63
64

TAPE
TIME
Troubleshooting

7,

1

TRSDOS
17-19
7

Definition

Start-up

Using

45

External Disk Cable with

Plugs Labeled

Free

Map

Full-Screen Format (debug)

get and put
Half-Screen Format (debug)
Input Process (input)
Inserting a Diskette

Model

III

2

(free)

51

43
50
40
129
7
1

Disk System

with External Drives

trsdos Memory Map
trsdos Roles

4
19
19

20

USING
USRn

133-4

93,113

VERF

81

Videooutput

47, 105

WP

65

WRITE

80-1

Write-protect notch

XFERSYS
Z-80

5
73
37, 39, 40, 41 48
55, 56, 63
,

&Hand&0

93-4

ja-sw
159

'

-'
:

:

:: ;
-

-

r:

siS'

:

^H^^B

'

:

'-»

an MAHPI
TP
IMUJIJEL,
rf2>"€fU
i

H!«5K
UISi\

HI

ISI

_

^f^TP
aiOIC
r

-

,

W8BSB8«m£Smt!S&

Radio Shack Software License
The following

are the terms and conditions of the

Radio Shack Software License

for

copies of Radio Shack software either purchased by the customer, or received with
or as part of hardware purchased by customer:

A. Radio Shack grants to

CUSTOMER

a personal, non-exclusive, paid

up license

to

use the Radio Shack computer software programs received. Title to the media

on which the software
transferred to the

B.

is

recorded (cassette and/or disk) or stored

CUSTOMER, but

In consideration for this license.

not

title to

CUSTOMER

(

ROM

)

is

the software.
shall not

reproduce copies of such

software programs except to produce the number of copies required for
personal use by

CUSTOMER

(if

the software allows a

and to include Radio Shack's copyright notice on
reproduced
C.

in

whole or

CUSTOMER may

resell

(modified or not,

in

copy of the software

all

backup copy to be made),
copies of programs

in part.

Radio Shack's system and applications software

whole or
for each

in part),

provided

CUSTOMER

has purchased one

one resold. The provisions of this Software

License (paragraphs A, B, and C) shall also be applicable

purchasing such software from

to third parties

CUSTOMER

Important Note
All

Radio Shack computer programs are licensed on an "as

is" basis without

warranty.
Radio Shack

shall

have no

liability or responsibility to

or entity with respect to any
directly or indirectly

liability, loss or

customer or any other person

damage caused

or alleged to be caused

by computer equipment or programs sold by Radio Shack,

including but not limited to any interruption of service, loss of business or
anticipatory profits or consequential

damages

resulting

from the use or operation of

such computer or computer programs.

Good data processing procedure dictates that
sample

sets of data,

and run the system

the user test the program, run and test

in parallel

with the system previously

for a period of time adequate to insure that results of operation of the

program

160

are satisfactory.

in

use

computer or

^^^^^^W^^^^^^^^H^^^Hi^S^Bi
service Policy
Radio Shack's nationwide network of service
and

reliable repair services for all of its

Warranty service

will be

performed

facilities

provides quick, convenient,

computer products

,

in

most instances

accordance with Radio Shack's Limited
Warranty. Non-warranty service will be provided at reasonable parts and labor
in

costs.

Because of the

sensitivity of computer equipment,

and the problems which can
from improper servicing, the following limitations also apply to the services
offered by Radio Shack:
result

1

2.

If any of the warranty seals on any Radio Shack computer products are broken,
Radio Shack reserves the right to refuse to service the equipment or to void any
remaining warranty on the equipment.

If any

Radio Shack computer equipment has been modified so that

it is

not

within manufacturer's specifications, including, but not limited to, the
installation of any non-Radio Shack parts, components, or replacement boards,
then Radio Shack reserves the right to refuse to service the equipment, void any

remaining warranty, remove and replace any non-Radio Shack part found in the
equipment, and perform whatever modifications are necessary to return the

equipment
3

to original factory manufacturer's specifications.

The cost for the labor and parts required to return the Radio Shack computer
equipment to original manufacturer's specifications will be charged to the
customer in addition to the normal repair charge.

161

,

tags* "=*" JO

ALL RADIO SHACK COMPUTER PROGRAf
"AS IS" BASIS WITHOUT WARRANTY.

IS

ARE LICENSED ON AN

Radio Shack shall have no liability or responsibility to customer or any
other person or entity with respect to any liability, loss or damage caused
or alleged to be caused directly or indirectly by computer equipment or
programs sold by Radio Shack, including but not limited to any interruption of service, loss of business or anticipatory profits or consequential
damages resulting from the use or operation of such computer or

computer programs.

Good

NOTE:

kefJ

data processing procedure dictates that the user test the
program, run and test sample sets of data, and run the system in
parallel with the system previously in use for a period of time
adequate to insure that results of operation of the computer or

program are

*afjX

satisfactory.

RADIO SHACK SOFTWARE LICENSE
F?S

\-f£

A. Radio

use on

Shack grants

to

CUSTOMER

CUSTOMER'S computer

received. Title to the media

the Radio Shack computer software
on which the software is recorded (cassette

and/or disk) or stored (ROM)
title

****

a non-exclusive, paid up license to

is

transferred to the

CUSTOMER,

but not

to the software.

B. In consideration for this license, CUSTOMER shall not reproduce
copies of Radio Shack software except to reproduce the number of copies
required for use on CUSTOMER'S computer (if the software allows a

it'****

backup copy to be made), and shall include Radio Shack's copyright
notice on all copies of software reproduced in whole or in part.
C. CUSTOMER may resell Radio Shack's system and applications software (modified or not, in whole or in part), provided CUSTOMER has
purchased one copy of the software for each one resold. The provisions
of this software License (paragraphs A, B, and C) shall also be applicable
to third parties purchasing such software from CUSTOMER.

jig; -Sj

ir%&# «?&?

LIMITED

WARRANTY

For a period of 90 days from the date of delivery, Radio Shack warrants to the
purchaser that the computer hardware unit shall be free from manufacturing defects. This warranty is only applicable to the original purchaser who
purchased the unit from Radio Shack company-owned retail outlets or duly
original

authorized Radio

Shack franchisees and dealers. This warranty is voided the
by purchaser to a third party. This warranty shall be
if

unit is sold ortransferred

if this unit's case or cabinet is opened, if the unit has been
subjected to
improper or abnormal use, or if the unit is altered or modified, if a defect occurs
during the warranty period, the unit must be returned to a Radio Shack store,

void

franchisee, or dealer for repair, along with the sales ticket or lease agreement.
Purchaser's sole and exclusive remedy in the event of defect is limited to the
correction of the defect by adjustment, repair, replacement, or complete
refund at Radio Shack's election and sole expense. Radio Shack shall have no
obligation to replace or repair

expendable items.

Any statements made by Radio Shack and

its employees, including but not
statements regarding capacity, suitability for use, or performance of
the unit shall not be deemed a warranty or representation by Radio Shack for
any purpose, nor give rise to any liability or obligation of Radio Shack.

limited to,

EXCEPT AS SPECIFICALLY PROVIDED IN THIS WARRANTY OR IN THE
RADIO SHACK COMPUTER SALES AGREEMENT, THERE ARE NO
OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL RADIO
SHACK BE LIABLE FOR LOSS OF PROFITS OR BENEFITS, INDIRECT,
SPECIAL, CONSEQUENTIAL OR OTHER SIMILAR DAMAGES ARISING
OUT OF ANY BREACH OF THIS WARRANTY OR OTHERWISE.
7-80

RADIO SHACK |j[ A DIVISION OF TANDY CORPORATION

FORT WORTH, TEXAS 76102
CANADA: BARRIE, ONTARIO L4M 4W5
TANDY CORPORATION
U.S.A.:

AUSTRALIA

BELGIUM

U.K.

280-316 VICTORIA ROAD
RYDALMERE, N.S.W. 2116

PARC INDUSTRIEL DE NANINNE
5140 NANINNE

BILST0N ROAD WEDNESBURY
WEST MIDLANDS WS10 7JN

87491 67-581 -SP

PRINTED

IN U.S.A.



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.5
Linearized                      : Yes
Page Layout                     : TwoPageRight
Page Count                      : 182
XMP Toolkit                     : XMP Core 4.1.1
Metadata Date                   : 2013:05:22 09:21:17Z
Create Date                     : 2013:05:22 09:13:19Z
Modify Date                     : 2013:05:22 09:21:17Z
Creator Tool                    : Digitized by the Internet Archive
Producer                        : Recoded by LuraDocument PDF v2.53
Part                            : 2
Conformance                     : B
Document ID                     : uuid:uuid:0307d17f-2045-56a8-c6b3-a8d7b476f422
Version ID                      : 2
Title                           : Radio Shack Hardware Manual: Model 3 Disk System Owners Manual (1980)(Tandy)[a]
Creator                         : Digitized by the Internet Archive
Keywords                        : http://archive.org/details/Model_3_Disk_System_Owners_Manual_1980_Tandy_a
EXIF Metadata provided by EXIF.tools

Navigation menu