Board index » delphi » Reading a file with ctrl Z before end of file
howl...@mail.airmail.net (TorchIT)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
howl...@mail.airmail.net (TorchIT)
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Reading a file with ctrl Z before end of fileHello all, |
Asbj?r
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileQuoteTorchIT wrote: bytes, until you reached the end, using the lenght_of_file function (i know it's not the proper name, but.. :) I'm not sure how the lenght_of_file function works, so... And perhaps the read procedure doesn't like reading ^Z. I don't know, give it a try. - Asbj?rn |
Bob Scho
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileQuote> Is there anyway to read a file that has a control z before the end of This is, in my opinion, an Implementation Bug (Feature?) of Borland's Pascal dialect. The file type "text" should treat ^Z as EOF if that's what your operating system suggests, as this file type is meant to be implementation-specific, and tailored to the concept of lines and (logical) EOF. The file type "char" should, on the other hand, treat the entire character set, which is also somewhat implementation-specific, but is probably either 7-bit Ascii, 8-bit Ascii, or EBCDIC; since we're talking PC-DOS, it's probably 8-bit Ascii, and ^Z is just another Ascii character. However, it looks like Borland is giving this character special significance, and using it as EOF. [Incidently, you might wonder if it treats ^@, 00H, the null character, as a real character, or whether it simply skips over it]. If so, you cannot use FILE OF char to solve your problem. How about trying PACKED FILE OF bytetype, where bytetype is defined as the restricted integer range -128 .. 127? You may have to experiment a bit, as it is again somewhat implementation-dependent whether this will work (an alternative declaration that might work if this doesn't is 0 .. 255). Now ^Z is simply the number 26. You can easily convert these bytes back into characters using the chr() function (though you may need to be careful if you get 8-bit Ascii values and have defined bytetype as -128..127). Bob Schor |
A Dude Who Progra
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileQuoteBob Schor <bsc...@vms.cis.pitt.edu> wrote: Glenn Grotzinger |
Scott Earnes
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileQuoteTorchIT wrote: usually just use this little program as a sort of filter to strip problematic text files. program stripEOFs; { Quickly removes all offending EOF (ASCII #26) characters from a Standard disclaimers apply. Quote} tblock = array[0 .. 32767] of byte; var begin Quote> Thanks, Scott Earnest | _,-""-_,-""-_,-""-_,-""-_,-""-_,-" | set...@ix.netcom.com (primary) | We now return you to our regularly | siny...@{*word*104}space.org (alternate) | scheduled chaos and mayhem. . . . | |
ASS-War
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileYou can convert your handle to a binary file handle, see the source of the -- ,,, TorchIT <howl...@mail.airmail.net> wrote in article Quote> Hello all, |
Frank Heckenba
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Reading a file with ctrl Z before end of fileQuoteBob Schor <bsc...@vms.cis.pitt.edu> writes: just tested with BP 7.0, and the file of char read properly behind the #26. For text files: They do stop at the #26, that's how they're designed. If you Hope this helps, |
1. Reading beyond the end of file code
3. Please help with error- Read Beyond End Of File
4. Read beyond end of file error!
5. error: read beyound end of file, why?
6. Help!! End of file characters in dBASE file
7. End of file use with tab delimited text file
8. Add Word file to end of Word file