rcj@killer.DALLAS.TX.US (Robert Johnson) (08/08/88)
What is the best way of reading a file, and then determinign when you have reached the end of it in TP4.0? I have tryed a while not EOF loop, but to no avail...I desperately need this! Any help appreciated, Robert P.S. Also: Is there a fast way to copy files of ANY size? Faster than dos copy, preferably.
edlee@chinet.chi.il.us (Edward Lee) (08/08/88)
In article <5126@killer.DALLAS.TX.US> rcj@killer.DALLAS.TX.US (Robert Johnson) writes: >What is the best way of reading a file, and then determinign when you >have reached the end of it in TP4.0? I have tryed a while not EOF >loop, but to no avail...I desperately need this! If you have a while-not-EOLN loop within a while-not-EOF loop, I suggest that you change the "not EOLN(file)" to "not ( EOLN(file) or EOF(file) )". For example: while not eof(file) do begin . . . while not eoln(file) do { MAKE: "while not( eoln(file) or eof(file) ) do"} begin . . . end; . . . end; { The last EOLN of a file can also be the EOF, so if only EOLN is checked in the inner loop, then the EOF check in the outer loop may fail. I had this problem with Watcom Pascal, involving an outer while-not-EOF with an inner repeat- until-EOLN loop, which I had to change to a repeat-until-EOLN-or-EOF loop. -Ed L }
gordon@eecea.eece.ksu.edu (Dwight Gordon) (08/08/88)
has always (?) had some difficulties with determining the end of file. If TP sees an eof ($1a) in the text input stream, EOF becomes true. As for speed and freedom from the text file restriction, try blockread and blockwrite. End of file on a blockread comes about when you attempt to read "n" blocks and you only read "i" blocks (i<n). Read the manual. You will need to use all four parameters for the blockread. If you set the block size to one (RESET(file,1)), you can determine the size of the file to the character. To make these routines fast, make the block size as large as possible under the 64K byte data segment restriction.
ralf@b.gp.cs.cmu.edu (Ralf Brown) (08/09/88)
In article <381@eecea.eece.ksu.edu> gordon@eecea.UUCP (Dwight W. Gordon) writes: }will need to use all four parameters for the blockread. If you set the block }size to one (RESET(file,1)), you can determine the size of the file to the }character. If all you want to do is determine the file's size, use longfilesize (TP3/4) or filesize (TP4). You want longfilesize in TP3 because filesize returns an integer, and is thus quite limited in the sizes it can report.... TP4's filesize returns a long integer. -- {harvard,uunet,ucbvax}!b.gp.cs.cmu.edu!ralf -=-=- AT&T: (412)268-3053 (school) ARPA: RALF@B.GP.CS.CMU.EDU |"Tolerance means excusing the mistakes others make. FIDO: Ralf Brown at 129/31 | Tact means not noticing them." --Arthur Schnitzler BITnet: RALF%B.GP.CS.CMU.EDU@CMUCCVMA -=-=- DISCLAIMER? I claimed something?
gordon@eecea.eece.ksu.edu (Dwight Gordon) (08/09/88)
My comment about Reset(file,1) was ment to address the need to use both the file-variable and the block size in the reset command. If you use the default file block size of 128 and the size of the file is not mod-128 then you will read garbage beyond end-of-file. Turbo deblocks the file into groups the size of the parameter in the Reset command. -- Dwight W. Gordon | 913-532-5600 | Electrical & Computer Engineering Department | dwgordon@ksuvm.bitnet | Kansas State University - Durland Hall | gordon@eecea.eece.ksu.edu | Manhattan, KS 66506 | {pyramid,ucsd}!ncr-sd!ncrwic!ksuvax1!eecea!gordon |