[Gambas-user] Writing to a file on disk

Rolf-Werner Eilert eilert-sprachen at ...221...
Wed Nov 10 17:14:24 CET 2010


Am 10.11.2010 16:46, schrieb NW:
> On Wed, 10 Nov 2010 14:38:57 +0000
> NW<hiems at ...2501...>  wrote:
>
>> My first question on the list.
>>
>> I am trying to read in a text file with just one line, to make a slight change to that line and then to write the new line to the original file on disk. The new line should replace the original line in the file.
>>
>> I can read in the file OK. I then use lineinput and copy the result to a text field. I can then make a change to the text.
>>
>> But I just cannot see how to write the file back to my hard disk with the new changed line in place of the original.
>>
>> Can anyone point me in the right direction please?
>>
>> Neil
>>
> Further info. I have almost solved it. Each time a write the file back to disk I get an extra character at the beginning of the line. So far I have tested it 7 times and I now have the letters FEDCBAN at the beginning of the line. Can anyone suggest where I should go next please?
>
> Neil
>

Maybe it's better you give us the lines you are using in your program to 
read and write the line. Then we should be able to see where the bug 
sits :-)

Did you try the File functions to do this? These should work without any 
headache: File.Read and File.Write. Look them up in the help.

If you prefer to open a stream for file writing, there are more things 
to be considered, best is you give us an idea of what you have written 
there...

Regards

Rolf




More information about the User mailing list