Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!adm!news From: CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) Newsgroups: comp.lang.pascal Subject: (R)Blockread/write problem Message-ID: <24336@adm.BRL.MIL> Date: 29 Aug 90 16:49:50 GMT Sender: news@adm.BRL.MIL Lines: 41 In article <9008290754.aa22853@VIM.BRL.MIL>, Edwin Groothuis writes > assign(fil1,'FILE.1');reset(fil1); {Sourcefile} > assign(fil2,'TEMP');rewrite(fil2); {Targetfile} > repeat > blockread(fil1,buffer,bufsize,recsread); > blockwrite(fil2,buffer,recsread); > writeln(recsread:5,' blocks written.'); > until recsread=0; >1. When I run this program, I don't get the whole file copied (I miss > several bytes). > > FILE.1 TEMP missing bytes: > 7056 7040 16 Carefully read the procedure BlockRead documentation in the RefGuide. The "result" variable (your recsread) returns the number of _complete_ "records" written. Since you opened the file with the default record size of 128 bytes, the final bytes (filesize mod 128) are not being written. "...a possible last partial record is not included in result." As suggested by others, open the file with a record size of 1. Your file I/O speed will not be affected. >2. When I reset a read-only file, why does TurboPascal then say that it > is impossible to open the file<> Refer to the FileMode variable documentation in the RefGuide. Altho sometimes a nuisance, this behavior is not a bug, is well-documented, and is easily dealt with. +-------------------------------------------------------------------------+ | Karl Brendel Centers for Disease Control | | phone 404/639-2709 Epidemiology Program Office | | fts 236-2709 Atlanta, GA | | | | Home of Epi Info 5.0 | +-------------------------------------------------------------------------+