Download Print this page

Commodore C2N Operating Instructions Manual page 17

Cassette unit suitable for use with vic, pet & cbm series computers
Hide thumbs Also See for C2N:

Advertisement

Here are some sample program segments which use the above
commands:
Example Program 1 – Writing Data
10 OPEN1,1,1,"TEST FILE"
20 FOR I=1 TO 10
30 PRINT#1,I
40 NEXT
50 CLOSE 1
Line 10 OPENs file 1 for WRITE as TEST FILE.
Line 20 Do everything between "FOR" & "NEXT" 10 times.
Line 30 PRINTs the variable I 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,1,0,"TEST FILE"
20 INPUT#1,D$
30 PRINT D$
40 IF ST=0 GOTO 20
50 CLOSE 1
Line 10 OPENs the file for READ as TEST FILE.
Line 20 Reads a string from the tape.
Line 30 Prints the 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 as the status is not OK – the end of file.
Example Program 3 – Reading Data using GET
10 OPEN1,1,0,"TEST FILE"
20 GET#1,D$
30 PRINT D$
40 IF ST=0 GOTO 20
50 CLOSE 1
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 as the status is not OK.

Advertisement

loading