Path: utzoo!attcan!uunet!jarthur!usc!samsung!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!ncifcrf!lhc!adm!news From: C0361%UNIVSCVM.BITNET@ncsuvm.ncsu.edu ( Thomas Jenkins) Newsgroups: comp.lang.pascal Subject: Turbo Pascal error : HELP! Message-ID: <23531@adm.BRL.MIL> Date: 6 Jun 90 00:44:25 GMT Sender: news@adm.BRL.MIL Lines: 77 Hello, Well, I've run into an error. I've written two programs in TP 5.5. One, FSPLIT, will accept two commandline arguments: a filename and a legal number. These are used to split the file into numberK chunks. The other program is FMERGE which requiers one (but will take two) parameters. These are used as the file name base (to merge files) and an optional output file name. Now some back ground: I've compiled and begun testing of both programs. At first they appeared to work perfectly. As far as I can tell, FMERGE still works fine. FSPLIT is giving me problems. When I split files into chunks greater than 30K, I get error 103: File not open at the BlockWrite instruction. When I run again with number of K being 30 or less, the program works fine. I am using Reset(f1,1) and ReWrite(f2,1). My buffer is defined as an array of 1 to MAXBUFFERSIZE of BYTE where MAXBUFFERSIZE is equal to 10240. The guts of the offending code looks like this: FUNCTION FCopy(VAR fIn,fOut :FILE; breakPoint :LONGINT) :BOOLEAN; TYPE BufferType = ARRAY(.1..MaxBufferSize.) OF BYTE; VAR numRead,numWritten :WORD; totalWritten,recsToRead :LONGINT; buffer :BufferType; OK :BOOLEAN; BEGIN OK := TRUE; {OK, I'm an optimis ;-)} totalWritten := 0; IF (breakPoint < SizeOf(Buffer)) THEN recsToRead := breakPoint ELSE recsToRead := SizeOf(buffer); REPEAT BlockRead(fIn,buffer,recsToRead,numRead); BlockWrite(fOut,buffer,numRead,numWritten); totalWritten := totalWritten + numWritten; UNTIL ( (numRead = 0) OR (numRead <> numWritten) OR (EOF(fIN)) OR (numRead < recsToRead) OR (totalWritten >= breakPoint) ); IF (numRead < recsToRead) THEN OK := FALSE; IF (EOF(fIn)) THEN OK := FALSE; IF (numRead <> numWritten) THEN Abort(12,'cannot split file!! Disk is full!!',''); FCopy := OK; END;{FCopy} Well, there it is. I can't figure out why it works for numberK <=30, but not for a larger cut. The buffer size is constant. I must be making a mistake, but can't pinpoint where it is. Those wishing a copy of one or both programs drop me a line and I'll send them out. Any help greatly appre., tom THOMAS E. JENKINS, JR. PROGRAMMER, UNIVERSITY OF SOUTH CAROLINA BITNET, C0361 AT UNIVSCVM.BITNET