[fpc-pascal] Blockread and buffers

Peter Vreman peter at freepascal.org
Tue Mar 22 08:36:36 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?

There are no warning/notes when compiled with 1.9.8.







More information about the fpc-pascal mailing list