Recent

Author Topic: Is it possible to use the EOF function with the FileRead function?  (Read 3848 times)

beampower

  • Newbie
  • Posts: 6
Is it possible to use the end of file (EOF) function with the file read (FileRead) function?

Free Pascal offers a list of file handling functions as listed here.
https://www.freepascal.org/docs-html/rtl/system/filefunctions.html
Reference for unit 'System' (#rtl)
EOF is part of the System set.

But there's another set of file handling functions included with sysutils.
https://www.freepascal.org/docs-html/rtl/sysutils/index-5.html
Reference for unit 'sysutils' (#rtl)
ReadFile is part of the Sysutils set.

System functions are not compatible with Sysutils functions?

Is there a comparable EOF function available in the Sysutils functions set?

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #1 on: July 25, 2017, 08:39:31 pm »
long story short: eof is for text files .
Speak postscript or die!
Translate to pdf and live!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #2 on: July 25, 2017, 08:40:10 pm »
Is it possible to use the end of file (EOF) function with the file read (FileRead) function?
No
System functions are not compatible with Sysutils functions?
No
Is there a comparable EOF function available in the Sysutils functions set?
Yes, FileRead returns number of bytes actually read. So when Count <> that returned value, EOF is reached.

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #3 on: July 25, 2017, 09:02:50 pm »
long story short: eof is for text files .
+1
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #4 on: July 25, 2017, 09:13:29 pm »
hint: eof involves parsing so its imposible to be used in bulk buffer read
Speak postscript or die!
Translate to pdf and live!

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #5 on: July 25, 2017, 09:19:43 pm »
hint: eof involves parsing so its imposible to be used in bulk buffer read
You're on a roll: +1 again.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #6 on: July 25, 2017, 09:32:12 pm »
long story short: eof is for text files .
Wait, What????

EOF() also works fine for files of records (or just File) not just text files:
Code: Pascal  [Select][+][-]
  1. Function  EOF(var f:File):Boolean;

You probably meant: EOF() is for Pascal file types and not for file-handles (which are used in FileRead).

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #7 on: July 25, 2017, 09:36:44 pm »
 O:-)just a wild gues .... seriously i did not read any mention of record related stuff so my opinion is about files of byte ok?
@rvk dont change the context do not try to make this a pascal knowledge exam.. ... grumpy  >:D
Speak postscript or die!
Translate to pdf and live!

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #8 on: July 25, 2017, 09:38:54 pm »
Well, EOF() is NOT just for text file. Period. (I'll leave it at that)

But I think Leledumbo described it best and gave an answer.

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Is it possible to use the EOF function with the FileRead function?
« Reply #9 on: July 25, 2017, 09:43:41 pm »
ok cool! peace! that why i wrote "long story short"
Speak postscript or die!
Translate to pdf and live!

 

TinyPortal © 2005-2018