[Gambas-user] Writing to a file on disk

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Nov 11 15:47:26 CET 2010


Am 11.11.2010 15:13, schrieb NW:
> On Thu, 11 Nov 2010 09:03:14 +0100
> Rolf-Werner Eilert<eilert-sprachen at ...221...>  wrote:
>
>> Hi Neil,
>>
>> Nice to read your code. Here are some comments on it:
>>
>>
>> Anyway, for simple textfile input/output, File.Read and File.Save will
>> be your friends.
>>
> As a follow up to this.
>
> I have searched around via Google and my A Beginner's Guide to Gambas book but I just cannot find out how to use File.Read and File.Save. Can anyone please start me off? I have played around with ideas for it but keep getting error messages.
>
> Many Thanks
>
> Neil
>

Sure, and Fabien has already given the example, so I quote him here. 
Copying his mail, I find something interesting he mentioned right at the 
beginning. I've never used that stuff, so just give it a try :-) Here is 
what he wrote:


have you tryed to replace result by a global string variable  ?

textbox use utf8 charset

and yes in your case ... use file.save


to resume your code

Private $sResult as string

PUBLIC SUB Button1_Click()

   $sResult = File.Load("/home/neilwin/basic/trial.txt")

END

PUBLIC SUB Button3_Click()

   File.Save("/home/neilwin/basic/trial.txt", $sResult)

END





Regards

Rolf




More information about the User mailing list