eof(fp) doesn't work with DJGPP and text files

General FreeBASIC programming questions.
Post Reply
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

eof(fp) doesn't work with DJGPP and text files

Post by mjs »

Hi,

when you use the FBC (for DOS) and try to load a text file in the following way:

Code: Select all

defint a-z

dim i as integer
dim l as string

print "Start"

open "test11.txt" for input as #1
while not eof(1)
	line input #1, l
    print "X",l
    i+=1
    if i>10 then print "Aborted": exit while
wend
close #1

print "End"
And the text file (text11.txt) contains of just a single EOF character (ASCII 26 / &H1A) then this program will print 10 lines instead of zero (or one). Please remember that this kind of files were very common in DOS enviroments.

The problem is in fb_FileEof when you check for the file pointer instead of feof() for an INPUT mode file.

Regards,
Mark
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

You've an email, welcome to the team ;).
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

v1ctor wrote:You've an email, welcome to the team ;).
Wow, thank you ... that's surprising me ...

Regards,
Mark
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

Heh, welcome. The more, the merrier. :) (We need all the help we can get..)
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Post by MystikShadows »

Where's my email? LOL..
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Post by Antoni »

mjs: Congatulations, new blood in the team is always welcome!

v1ctor: Tie short that guy or you will end with FB compatible with #%$@ syntax :D

Mystik: We have all been accepted as nitpickers and curmudgeons months ago...
Post Reply