on Apr 24th, 2010, 08:19am, Dyna wrote:How would I go about writing this in BBC basic? |
|
Code: REM LOAD FILE
Mydata$ = @dir$ + "Data\MyData.txt"
infile = OPENIN(Mydata$)
IF infile=0 THEN ERROR 53, "Cannot open file"
WHILE (NOT EOF #infile)
INPUT #infile, Name$(a)
a = a + 1
ENDWHILE
CLOSE #infile
Count = a
REM ******SAVE DATA ******
Mydata$ = @dir$ + "Data\MyData.txt"
outfile = OPENOUT(Mydata$)
IF outfile=0 THEN ERROR 53, "Cannot create file"
FOR a = 0 TO Count
PRINT #outfile, Name$(a)
NEXT a
CLOSE #outfile
The file's records will be terminated by CR (CHR$13). If you want to read/write a CRLF-terminated file you need to add a little code thus:
Code: INPUT #infile, Name$(a)
IF ASC(Name$(a))=10 THEN Name$(a) = MID$(Name$(a),2)
Code: PRINT #outfile, Name$(a)
BPUT #outfile, 10
Richard.