[Gambas-user] Writing to a file on disk

NW hiems at ...2501...
Wed Nov 10 20:11:56 CET 2010


On Wed, 10 Nov 2010 19:21:47 +0100
Fabien Bodard <gambas.fr at ...626...> 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
> 
> 
> 
> 
> But i think you want to modify somethong on a line so :
> 
> 
> dim s as string
> Dim sFile as string
> Dim hFile as File
> Dim sTempName as String
> Dim sMyFile as String = "/home/neilwin/basic/trial.txt"
> 
> sTempName = Temp()
> 
> hFile = Open sTempName FOR CREATE
> 
> sFile = File.Load( sMyFile)
> 
> For each s in split(sFile, "\n")
> 
>   if trim(s) Begin "Var=" then
>      s = "coucou"
>   endif
> 
>   print #hFile, s
> 
> next
> 
> close #hfile
> kill sMyFile
> copy sTempFile TO sMyFile
> 
Wow, thanks. I have made a copy of your suggestions and I will study it all carefully. I will then have a go at it. There is still a lot for me to learn about Gambas. Thank goodness there is this help list.

I will let you know how I get on,

regards

Neil




More information about the User mailing list