[Gambas-user] EOF problem

Dimitris Anogiatis dosida at ...626...
Sun Apr 18 04:39:16 CEST 2010


Ed can you try this and tell us if it still doesn't work?

PUBLIC SUB Button1_Click()

  DIM tfile AS File
  DIM Fname AS String
  Dim temp AS String

  Fname = "/home/us/Documents/testdat.txt"

  tfile = OPEN Fname FOR READ

  label1.Text = ""

  IF Eof(tfile) THEN
     label1.Text = "EOF"
     Print "EOF"
  ELSE
     LINE INPUT #tfile, temp
     Print temp
  END IF

  CLOSE #tfile

END

Watch the IDE's debug window to see what's being printed as the file is
being read

If this doesn't work too then you could try to update your version of
Gambas2 since
the latest stable version is 2.20.2

I hope this helps

Regard
Dimitris


On Sun, Apr 18, 2010 at 2:25 AM, Ed & Clare Kelm
<twopilots at ...2415...>wrote:

> Thanks for the quick reply!
>
> 1.  The problem is independent of the contents of the text file.
>
> 2.  I tried a more complicated test program in which there are TWO
> buttons, and TWO different text files.  This behaves similarly;  most of
> the time, failure of one button/file will be  accompanied by  failure of
> the other, but not always.   Very occasionally, one button/file will
> work, one will fail.
>
> 3.  According to Synaptics Package Manager I have the latest version of
> Gambas available, called 2.8.2-1build1 - if there is a newer version,
> how would I find and install it?
>
> 4.  Would it be worth trying an upgrade to Ubuntu 9.10?
>
> Regards,
>
> Ed K.
>
> Benoît Minisini wrote:
> >> Hi!
> >>
> >> I'm having a problem reliably reading a text file.
> >>
> >> I am using:
> >>
> >> Panasonic CF-51 Toughbook
> >> Ubuntu 9.04 , Kernel 2.6.28-18
> >> Gambas 2.8, QT
> >>
> >> Below is the code for a test program which demonstrates the problem.
> >> This is a simple form, with one button, and one label. The only code is
> >> the Button1_click event shown.  The file "testdat.txt" contained in
> >> Fname is a text file with one short line of text, created with GEDIT.
> >>
> >> One would expect that clicking Button1 would open the file, read the
> >> line of text, and place it into label1.  Indeed, this is exactly what
> >> happens roughly 4 times out of 5.  However, sometimes the file comes up
> >> empty, with an immediate EOF.  When the program is first started from
> >> the IDE, if it works correctly the first time, it will do so every time
> >> the button is clicked.  However, if it fails (indicates EOF) the first
> >> time, it will fail everytime the button is clicked.  Stopping the
> >> program and restarting it will roll the dice anew.  There does not seem
> >> to be any pattern to the failure.  It might happen twice in a row, it
> >> might not happen for 10 starts.
> >>
> >> Does anybody have any ideas?  Is this an Ubuntu issue?
> >>
> >> Thanks!
> >>
> >> Ed K.
> >>
> >>
> >> PUBLIC SUB Button1_Click()
> >>
> >>    DIM tfile AS File
> >>    DIM Fname AS String
> >>
> >>    Fname = "/home/us/Documents/testdat.txt"
> >>
> >>    tfile = OPEN Fname FOR READ
> >>
> >>    label1.Text = ""
> >>
> >>    IF Eof(tfile) THEN
> >>       label1.Text = "EOF"
> >>    ELSE
> >>       LINE INPUT #tfile, label1.Text
> >>    END IF
> >>
> >>    CLOSE #tfile
> >>
> >> END
> >>
> >>
> >
> > I cannot reproduce the problem with the same code. Does it occur whatever
> the
> > contents of 'testdat.txt' is? Can you try the latest version of Gambas 2?
> >
> >
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> 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