Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!wuarchive!udel!haven!adm!news From: CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) Newsgroups: comp.lang.pascal Subject: (R)Blockread/write problem Message-ID: <24352@adm.BRL.MIL> Date: 31 Aug 90 12:56:55 GMT Sender: news@adm.BRL.MIL Lines: 46 In <26DE0F04.26212@ics.uci.edu> Alastair Milne writes: >In <1990Aug29.123053.17412@ux1.cso.uiuc.edu> dslg0849@uxa.cso.uiuc.edu (Daniel > S. Lewart) writes: > >>>1. When I run this program, I don't get the whole file copied (I miss severa >>> bytes). >>> FILE.1 TEMP missing bytes: >>> 7056 7040 16 >>> 6899 6784 115 >>> 6296 6272 24 >>> 3040 2944 96 > >>Notice that all the TEMP sizes are multiples of 128, the default record size. >>Try reset(fil1,1) instead. > > Doing an entire BlockRead for a single byte seems a waste of the routine, > and probably invites a lot of overhead. If you want to do single-characte > I/O, skip BlockIO altogether and just use FILE OF BYTE, with plain READs. > May even be faster than BlockIO. The suggestion is not to BlockRead one byte at a time, but to use a record size of one byte. The BlockRead can still access as many bytes as in the original. I suspect that all typed file I/O becomes equivalent to BlockI/O in the end, so I doubt that Read(some file of byte) can be any faster than BlockRead. > I suspect you are not getting the whole file copied because BlockRead's > last call causes a non-zero IOResult because of not being able to read a > full 128-byte block. This would keep BlockWrite from doing any further Because the original code provided a variable for the optional "result" parameter, BlockRead would not cause an I/O error (or a non-zero IOResult) when reading the last partial block. It _would_, indeed, read that partial block into the buffer. Unfortunately, there would be no explicit indication that a partial block had been read. +-------------------------------------------------------------------------+ | Karl Brendel Centers for Disease Control | | phone 404/639-2709 Epidemiology Program Office | | fts 236-2709 Atlanta, GA | | | | Home of Epi Info 5.0 | +-------------------------------------------------------------------------+