Alright then:
If file exist("afile.txt") then delete file "afile.txt"
open to write 1,"afile.txt"
writestring(1,"This is a test!")
writestring(1,"This is another test!")
writestring(1,"This is the final test!")
close file 1
open to read 1,"afile.txt"
a$ = readstring(1)
b$ = readstring(1)
c$ = readstring(1)
close file 1
print a$
print b$
print c$
wait key
end
function WriteString(filenum as integer, a as string)
For x = 1 to LEN(a)
write byte filenum,ASC(MID$(a,x))
Next x
write byte filenum,13
write byte filenum,10
endfunction
function ReadString(filenum as integer)
b as string
Do
read byte filenum,a
If (a = 10 and prev = 13) or file end(filenum) then exit
If prev>0 then b = b + CHR$(prev)
prev = a
Loop
endfunction b
Now it won't crash. And the write string documentation says it terminates a string with a carriage return.
The optomist's right, The pessimist's right.