home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex18.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  511 b   |  25 lines

  1. program ex18;
  2.  
  3. { Program to demonstrate the TStream.Read method }
  4.  
  5. Uses Objects;
  6.  
  7. Var Buf1,Buf2 : Array[1..1000] of Byte;
  8.     I : longint;
  9.     S : PMemorySTream;
  10.     
  11. begin
  12.   For I:=1 to 1000 do
  13.     Buf1[I]:=Random(1000);
  14.   Buf2:=Buf1;
  15.   S:=New(PMemoryStream,Init(100,10));
  16.   S^.Write(Buf1,SizeOf(Buf1));
  17.   S^.Seek(0);
  18.   For I:=1 to 1000 do
  19.     Buf1[I]:=0;
  20.   S^.Read(Buf1,SizeOf(Buf1));
  21.   For I:=1 to 1000 do
  22.     If Buf1[I]<>buf2[i] then 
  23.       Writeln ('Buffer differs at position ',I);
  24.   Dispose(S,Done);
  25. end.