Blockread/Blockwrite question 
Author Message
 Blockread/Blockwrite question

I've written the following program.

--------------------------------------------------------------------------------------------------------------------

program CopyFile;
var
  FromF, ToF: file;
  NumRead, NumWritten: Word;
  Buf: array[1..2048] of Char;
begin
  Assign(FromF, ParamStr(1));
  Reset(FromF,1); <----------------------------------(if val2 = 1)
  Assign(ToF, ParamStr(2));
  Rewrite(ToF, 1); <----------------------------------(if val1 = 1)
  Writeln('Copying ', FileSize(FromF), ' bytes...');
  repeat
    BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
    BlockWrite(ToF, Buf, NumRead, NumWritten);
    writeln('----> ',numread:3,' ',numwritten:3);
  until (NumRead = 0) or (NumWritten <> NumRead);
  Close(FromF);
  Close(ToF);
end.
--------------------------------------------------------------------------------------------------------------------

Actually, I copied it from the BLOCKREAD listing in the help file. I
also created a.txt shown below.

-------------------------------------
13247832
232784032
3327849
4329432
-------------------------------------

There are 31 numbers in a.txt, but a.txt is 39 bytes in size because of
the carriage returns and line feeds
at the end of each line. Notice that the recsize that I'm using in my
reset and rewrite statements is both
= 1. I've experimented with different values in the reset and rewrite
statements. I've noticed that when
rewrite has say, val1 and reset has val2 and when you have a.txt and
b.txt as the command line
parameters, then the filesize of b.txt is equal to (filesize(a.txt) div
val1) * val2. For example, if you
have reset(FromF,8) and rewrite(ToF,3) in the above program, and the
filesize of a.txt is 39, then the
filesize of b.txt is (39 div 8) * 3 = 12.

Well, here is my question. I've noticed that if you are using a.txt as
your first command line parameter
and val1 = 32, then the filesize of b.txt is 0. I've even tried
experiments with another file called c.txt which has a filesize of 135.
If I type copyfile c.txt b.txt and val1 has a value of

--
Patrick D. Rockwell





Fri, 23 Apr 2004 07:18:39 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Blockread/Blockwrite question.

2. BLOCKREAD&BLOCKWRITE?

3. Urgent help needed with GFx mode and BlockRead/BlockWrite

4. blockread/blockwrite

5. Blockread / Blockwrite

6. How do I use BLOCKREAD/BLOCKWRITE

7. Problems using seek and blockwrite

8. Blockwrite

9. blockwrite anomaly?

10. BlockWrite

11. BlockWrite problem.

12. Blockwrite constant

 

 
Powered by phpBB® Forum Software