On Wed, 10 Nov 2010 17:14:24 +0100
Rolf-Werner Eilert <eilert-sprac...@t-online.de> wrote:

> >
> 
> 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
> 
Here is some more information.
I have a form which includes two buttons. The first one is for reading in the 
file, (which has only one line of text). Here is my coding.

PUBLIC SUB Button1_Click()

  DIM lineIn AS String
  DIM fileIn AS File
  DIM fname AS String
  fname = "/home/neilwin/basic/trial.txt"
  
  OPEN fname FOR READ AS #fileIn
  LINE INPUT #fileIn, lineIn
  result.Text = ""  
  result.text = result.text & lineIn
  FLUSH #fileIn
  CLOSE #fileIn

END

There is also a text box which I have renamed result.  I make a few changes to 
the line of text and then I click on another button to write the changed file 
back to the hard disk. Here is the code

PUBLIC SUB Button3_Click()

  DIM fileIn AS File
  DIM fname AS String
  fname = "/home/neilwin/basic/trial.txt"
  OPEN fname FOR CREATE AS #fileIn
   WRITE #fileIn, result.Text
   CLOSE #fileIn

END

Perhaps I should add that I am new to Gambas but not new to computers.

When I check the new version of the file in Konqueror  the changes are there 
but there is one extra character at the very start of the line. 

Is there a better way to do what I want?  Thanks for any help,

Neil

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to