Radio Shack TRS-80 Model 100 Basic Manual page 134

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

After the program has been entered, insert a blank cassette, rewind it, and advance it
past any leader. Press the PLAY and RECORD keys on the recorder and then execute
the program.
The recorder will run for a few seconds and then stop; when it does, the names stored
in RAM "NAMES.DO" will be displayed as:
John Smith
Peter Wolf
Aloysius T. Cornpone
Jim Shoe
Steele Ma!1net
Ray D. O'Shack
Finally, the recorder will run for a few more seconds as the program writes the names
to the cassette file. The data file has now been transfered to cassette.
Line 188 The MAXFILES statement limits the maximum file number which may be
used, in this case, two. If you want to open more than one file at a time, you must
first declare the maximum number of files with the MAXFILES statement.
As usual, the CLS statement clears the display.
Line 118 This OPEN statement assigns the file number I to the RAM file
NAMES. DO. Since this file will be read, it is declared an INPUT file.
Line 128 This OPEN statement assigns the file number 2 to the cassette file NAMES.
Since this file will be written to cassette, it is declared an OUTPUT file.
Line 138 The statement INPUT #I,N$ reads the name from the RAM file and stores
it in the string variable N$. The PRINT #2,N$ statement writes the name to the
cassette file. The statement PRINT N$ displays the name.
Line 148 If the end of the RAM file has not been reaChed, the program jumps back to
line 130, where the next name will be read.
Line 158 When the end of file is reached, both open files are closed. A CLOSE
statement closes all open files. If you wish to close a specific file, add the file number
to the CLOSE statement as in
CLOSE 1
You can verify that the file has been transfered properly to cassette by loading in
program "EXP2," rewinding the cassette, pressing the PLAY key and running the
program. If you have done everything correctly, the names will display as soon as the
file has been read in.
Experiment #6 Writing a numerical data file
In this experiment, a data file containing 30 numbers representing sales data will
be
created. The table below gives daily sales data for six weeks which will be saved in a
RAM file for later use.
Week Man Tue Wed Thu Fri
1
280 275 3aG 280 250
2
300 2G0 320 300 2a2
128

Advertisement

Table of Contents
loading

Table of Contents