Ace of diamonds
0
COMMENT
Notice the use of DATA statements to hold a permanent file of data which the program always uses.
The other data which changes each time the program runs is entered through an INPUT statement. If
the input data was known before running the program it would be equally correct to use another
READ and more DATA statements. This would give better control.
SEQUENTIAL DATA FILES
The following program will establish a file of one hundred numbers.
100 REMark Number File
110 OPEN NEW #6,mdv1_numbers
120 FOR num = 1 TO 100
130 PRINT #6,num
140 END FOR num
150 CLOSE #6
Numeric File
After running the program check that the filename 'numbers' is in the directory by typing:
DIR mdv1_numbers
You can get a view of the file without any special formatting by copying from Microdrive to screen:
COPY mdv1_numbers to scr
You can also use the following program to read the file and display its records on the screen.
100 REMark Read File
110 OPEN_IN #6,mdv1_numbers
120 FOR num = 1 TO 100
130 INPUT #6,item
140 PRINT ! item !
150 END FOR num
160 CLOSE #6
If you wish you can alter the program to get the output in a different form.
Character File
In a similar fashion the following programs will set up a file of one hundred randomly selected letters
and read them back.
100 REMark Letter File
110 OPEN NEW #6,mdv1_chfile
120 FOR num = 1 TO 100
130 LET ch$ = CHR$(RND(65 TO 90))
140 PRINT #6,ch$
150 END FOR num
160 CLOSE #6
100 REMark Get Letters
110 OPEN IN #6,mdv1_chfile
120 FOR num = 1 TO 100
130 INPUT #6,item$
140 PRINT ! item$ !