Q.
Why data written to a file using a WRITE statement cannot be read using a READ statement.

A.
In Full BASIC, a file opened without appointing RECTYPE shall be of display record type. As WRITE statements record data as PRINT statements do when they are applied for a file of display record type, the data cannot be read using READ statements.
In Full BASIC, WRITE and READ requires a file to be opened as an internal file appointing RECTYPE INTERNAL, otherwise they act as PRINT and INPUT.

Example (write out)

100 DATA "Tom", 56, 74
110 DATA "Becky", 92, 83
120 OPEN #1: NAME "A:sample.CSV",RECTYPE INTERNAL
130 ERASE #1
140 DO
150    READ IF MISSING THEN EXIT DO: s$, x,y
160    WRITE #1: s$,x,y
170 LOOP
180 CLOSE #1
190 END
Example (read in)
10 OPEN #1: NAME "A:sample.CSV",RECTYPE INTERNAL
20 DO
30    READ #1,IF MISSING THEN EXIT DO: s$, x,y
40    PRINT s$,x,y
50 LOOP
60 CLOSE #1
70 END
 
Back