[fpc-pascal]TFileStream

ron wilson ron.wilson at coastgames.com
Thu Sep 6 17:11:37 CEST 2001


ok - i have been here before...
http://www.freepascal.org/docs-html/classes/index.html

TFileStream inherits from THandleStream which inherits from TStream.  i am
still having problems figuring out how to do error handling.  for example,
let me give some generic code for what i need:

open(stream)
while not(eof(stream))
 line=readln(stream) <-- read to cr/lf
 parse(line)
end
close(stream)

or -

open(stream)
while not(eof(stream))
 packet=read(stream,size) <-- read a record of fixed length
 parse(packet)
end
close(stream)

i guess my problem is that i can find no examples of file handling that
doesn't assume a known file size.  i suppose i could compare the size and
position properties of the stream and write my own eof function, but i just
assumed that this kindof method would be standard.

does anybody have a fuller example that i could work from - something more
developed?  i don't know what 90% of the TStream methods and properties are
for.  why write code myself if the class already does what i need?  should i
just write another class that inherits from TFileStream?

regards,
ron wilson
icq 83250263

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

There is a preliminary but quite complete&accurate
version of the documentation on

http://www.freepascal.org/docs-html/classes/index.html

Look at the classes section, TFileStream. It is completely documented

...

You can always use the FileCreate/FileOpen/FileRead/FileWrite
functions of the SysUtils unit. These are about the most low-level functions
you can get, and they are cross-platform.

Michael.

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----





More information about the fpc-pascal mailing list