[Gambas-user] write to file question
Jesus
ea7dfh at ...2382...
Wed Aug 17 15:43:38 CEST 2011
El 15/08/11 14:03, wally escribió:
> Hi,
>
> i try to write data to a new file in the following way:
>
> Public hFile As File 'because i need to write in a serial_read_event
>
> hFile = Open Application.Path &/ "prot.log" For Write Create
>
> Write #hFile, Hex$(iByte, 2)
>
> hFile.Close
>
> Problem is that the filesize is growing during run and the containing data is
> as wanted. If i break the execution all is OK.
> When i use hFile.Close the file remain but is empty.
>
> What i need to do ?
> thank you
> wally
It sounds like you are executing that code into a loop, may be a
for..next or While..wend; That's not so important. The fact is that
"Write create" is creating a new file each time the loop executes,
erasing the content of your recent created file.
If in the last step of your loop you're not writing something, the file
appears as empty. You could try appending content to the file instead,
using the "append" keyword at the end of your statement:
> hFile = Open Application.Path &/ "prot.log" For Write Append
Hope that helps, regards.
--
Jesus Guardon
More information about the User
mailing list