Download Print this page

Commodore C2N Operating Instructions Manual page 18

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 X=1TO10
30 PRINT# 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 IF ST=0 GOTO 20
50 CLOSE 1
Line 10 OPENSs 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"'
20 GET# 1,D$
30 PRINT D$
40 IF ST=0 GOTO 20
50 CLOSE1
Line 10 OPENSs 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.

Advertisement

loading
Need help?

Need help?

Do you have a question about the C2N and is the answer not in the manual?