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

  1. Program ex16;
  2.  
  3. { Program to demonstrate the TStream.Truncate method }
  4.  
  5. Uses Objects;
  6.  
  7. Var L : String;
  8.     P : PString;
  9.     S : PDosStream; { Only one with Truncate implemented. }
  10.     
  11. begin
  12.   L:='Some constant string';
  13.   { Buffer size of 100 }
  14.   S:=New(PDosStream,Init('test.dat',stcreate));
  15.   Writeln ('Writing "',L,'" to stream with handle ',S^.Handle);
  16.   S^.WriteStr(@L);
  17.   S^.WriteStr(@L);
  18.   { Close calls flush first }
  19.   S^.Close;
  20.   S^.Open (stOpen);
  21.   Writeln ('Size of stream is : ',S^.GetSize);
  22.   P:=S^.ReadStr;
  23.   L:=P^;
  24.   DisposeStr(P);
  25.   Writeln ('Read "',L,'" from stream with handle ',S^.Handle);
  26.   S^.Truncate;
  27.   Writeln ('Truncated stream. Size is : ',S^.GetSize);
  28.   S^.Close;
  29.   Dispose (S,Done);
  30. end.