[fpc-pascal] Blockread and buffers

Michał Woźniak mikiwoz at yahoo.co.uk
Tue Mar 22 00:07:27 CET 2005


Hmmm... Just pure curiosity:
I am getting a warning "Variable does not seem to be initialized" on a code 
from FreePascal RTL guide:

Var Fin, fout : File;
    NumRead,NumWritten : Word;
    Buf : Array[1..2048] of byte;
    Total : Longint;

begin
  Assign (Fin, Paramstr(1));
  Assign (Fout,Paramstr(2));
  Reset (Fin,1);
  Rewrite (Fout,1);
  Total:=0;
  Repeat
    BlockRead (Fin,buf,Sizeof(buf),NumRead); // <-- Warning here (buf)
    BlockWrite (Fout,Buf,NumRead,NumWritten);
    inc(Total,NumWritten);
  Until (NumRead=0) or (NumWritten<>NumRead);
[snip]

Address: http://www.freepascal.org/docs-html/rtl/system/blockread.html

I have used similar code for ages and had no problems, but...
Am I missing something? Should the buf be initialized (and if so - how) 
somewhere before?

TIA
Mike





More information about the fpc-pascal mailing list