[Gambas-user] write to file question

Jussi Lahtinen jussi.lahtinen at ...626...
Wed Aug 17 17:24:13 CEST 2011


Or, put "Open" outside of the loop.

Jussi


On Wed, Aug 17, 2011 at 16:43, Jesus <ea7dfh at ...2382...> wrote:

> 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
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list