![Commodore 1531 Datassette Скачать руководство пользователя страница 18](http://html1.mh-extra.com/html/commodore/1531-datassette/1531-datassette_user-manual_2643350018.webp)
Here are some sample program segments which use the above commands:
Example program 1 — writing data
10 OPEN1,1,1,"TEST FILE"
20 FORX=1T010
30 PRINTS 1,X
40 NEXT
50 CLOSE1
Line 10 OPENs file 1 for WRITE as TEST FILE.
Line 20 Do everything between "FOR"&"NEXT" 10 times.
Line 30 PRINTS the variable 1 on to the tape.
Line 40 Goes back to line 20 for 10 times.
Line 50 CLOSES the file.
Example program 2 — reading data using INPUT
10 OPEN1,1,0,'TEST FILE"
20 INPUT#1,D$
30 PRINT D$
40 IFST=OGOT020
50 CLOSE 1
Line 10 OPENS the file for READ as TEST FILE.
Line 20 Reads a string from the tape into D$.
Line 30 Prints the value of D$ on the screen.
Line 40 Checks the status of the cassette. If the tape is OK then GOTO line 20.
Line 50 CLOSES the file.
Example program 3 — reading data using GET
10 OPEN1,1,0,'TEST FILE"
20GET#,1,D$
30 PRINT D$
40 IFST=OGOT020
50 CLOSE1
Line 10 OPENS the file for READ as TEST FILE.
Line 20 GETs a character into D$.
Line 30 Prints the character in variable D$ on the screen.
Line 40 Checks the status of the cassette. If the tape is OK then GOTO line 20.
Line 50 CLOSES the file.