[Gambas-user] EOF problem
Les Hardy
les at ...2337...
Sun Apr 18 21:11:29 CEST 2010
Doriano Blengino wrote:
> Les Hardy ha scritto:
>
>> Hi Ed,
>> I figured it out.
>> First of all, depending how the text file was emptied/created, the
>> contents may not be truely empty.
>> Gedit for example leaves the 0A (end-of-line) character in the 'empty'
>> file. This is recognised by eof() as a character, so, end-of-file is not
>> found.
>> I am not sure if this can be considered a bug in Gambas, but it does
>> mean an eof() is only good for preventing read errors, and is not
>> reliable for testing if a file is empty.
>>
>>
> Just breaking in to say that a file with a EOL in it is not an empty
> file - it is a file with an empty line in it...
> Given such a file, at first EOF is false; doing a LINE INPUT an empty
> line is read, then EOF turns true. Or, at least, it should go this way.
>
> Regards,
>
>
Your correct, I agree completely, but the original code Ed supplied, '
IF Eof(tfile) ' cannot work , as it checks eof before a read.
When I saw he was using eof() that way, and knowing empty files are not
always empty, I thought I had found his problem, so I just added a bit
of code that should have got around it.
I am sure you will agree, that, whatever other problems he may have, he
needs not to use eof() the way he is.
Regards
Les Hardy
More information about the User
mailing list