View Full Version : File writing


Spectrum
01-02-08, 03:29 AM
I need help writing to a file that is running. I am programming in QBasic but any advice would be welcome (preferably debug for windows (which I understand is an assembler)). My programs are as follows:

open [THISFILENAME$] for random as #1
while eof(1)=0
get #1
put #1
wend
close #1


...or...

open [THISFILENAME$] for random as #1
for address=1 to lof(1)
get #1, address
put #1, address
next address
close #1

The programs above do write to the file but I have to close down the program to see what has been written. I want the data to be written to the file, not simply to memory.

Stryder
01-02-08, 07:36 AM
According to my quickreference (since I don't program in QBasic) you are missing something out from the initial file open:

OPEN [THISFILENAME$] for RANDOM AS #1 LEN = LEN(RecordVariable)


I couldn't tell you if this is helpful at all, from what I can work out, using the RANDOM file access allows both Read and Write at the same time, you could try writing to a file using APPEND or OUTPUT to see whether or not your syntax is correct. (That's what I would try anyhow)

The only other possibility is that you are using the #1 for more than one file access at a time and this could cause conflicts on closing.

Spectrum
01-02-08, 07:53 AM
Stryder, thanks for your wise reply. However I get the same result when I use open [THISFILE$] for random as #1 len=1