home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!auspost.com.au!simon
- From: simon@guk.auspost.com.au (Simon Carter)
- Subject: Re: Fast "COPY" Routine help...PLEASE.
- Message-ID: <1993Jan22.000258.3503@auspost.com.au>
- Sender: usenet@auspost.com.au (USENET Administrator)
- Organization: Australia Post
- X-Newsreader: TIN [version 1.1 PL6]
- References: <93019.173648SJS132@psuvm.psu.edu>
- Date: Fri, 22 Jan 1993 00:02:58 GMT
- Lines: 54
-
- SJS132@psuvm.psu.edu wrote:
- : [Stuff deleted!]
-
- {I don't have any Turbo stuff here, so minor detailse may be incorrect}
-
- * Firstly, you are opening the OutFile in READONLY mode. Change the
- FileMode before rewriting it.
-
- * Use a record size of one byte when opening the files. Otherwise,
- if the file is not an integral number of records long, the incorrect
- number of bytes will be written.
-
- * You don't need {$I-} {$I+} around the BlockRead unless you are
- performing some error checking. It you include the 4th
- variable (BytesGot <- which incidentally should be RecordsGot), no
- error is produced if less than the requested number of records
- can be read.
-
- * Let me suggest the following:
-
-
- Assign(Infile,FileName); {Assign the File}
- Assign(OutFile,Path); {Assign the File}
-
- FileMode := 0; {Open the INFILE as READONLY}
- Reset(Infile,1); {Open the input}
-
- FileMode := 1; {Open OUTFILE as WRITEONLY}
- Rewrite(OutFile,1); {Create or clear the output}
-
- repeat
- BlockRead(InFile,BP^,RecSize,BytesGot);
- BlockWrite(OutFile,BP^,BytesGot);
- until (BytesGot < RecSize);
-
- Close(Outfile);
- Close(Infile);
-
-
- * If you are writing a copying program (unless it's for you own
- exclusive use), you should be checking the value of ParamCount BEFORE
- using ParamStr(1) and ParamStr(2). Check they exist before
- blindly using them!
-
-
- Hope this helps,
-
- Simon
- --
- +-----------------------------------------------------------+
- | Simon Carter: 3rd Year Elec/Comp Sci, Monash Uni, Clayton |
- | Net: simon@auspost.com.au (currently) \\|// |
- | /simon% find -greatquotes -print >> .signature (o o) |
- +-----------------------------------------------ooO-(_)-Ooo-+
-