Ok the wiki says that the whole array can be written to a file like
DIM string2(16384) AS STRING
****
PUT #1, , string2() 'file write
I get the error message:
"cannot pass array of variable- length strings on current line"
but there is no such error for :
GET #1, , string2() 'file read
And here is where it gets ugly
if I DIM it like:
DIM string2(16384) AS STRING * 1
then the
"cannot pass array of variable- length strings on current line"
goes away - but instead I now get another error:
"C++ compilation failed"
****
From the wiki you can see how GET and PUT are used
DIM SHARED array(100) AS INTEGER
FOR i = 1 TO 100
array(i) = i
NEXT
showme 'display array contents
OPEN "BINFILE.BIN" FOR BINARY AS #1
PUT #1, , array()
ERASE array 'clear element values from array and display empty
showme
CLOSE #1
OPEN "BINFILE.BIN" FOR BINARY AS #2
GET #2, , array()
CLOSE #2
showme 'display array after transfer from file
I can't get it to work
ive never had to do
DIM string2(16384) AS STRING * 1
and it seems to bork the complier
Actually I've
never had to use an array to do file read / writes. There is absolutely no point in doing so. I sure miss the DOS interrupts at this point :(
I have always found that
DIM string1 AS STRING * 16384
was sufficient for file read / writes, because that DIM actually reserves a block of memory. You can see the block in the EXE file if you look at it with a hex editor.
****
I wish QB64 had ReadFile and WriteFile
DIM string1 AS STRING * 16384
WriteFile #1, string1, nbytes
ReadFile #1, string1, nbytes
where nbytes is the number of bytes to read or write.
string1 is a FIXED length string
string1 is simply a file buffer in this case. You certainly don't need the overcomplication of an array or the bizarre implications of a variable length string to do that.