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

  1. Program ex14;
  2.  
  3. { Program to demonstrate the TStream.Close method }
  4.  
  5. Uses Objects;
  6.  
  7. Var L : String;
  8.     P : PString;
  9.     S : PDosStream; { Only one with Close implemented. }
  10.     
  11. begin
  12.   L:='Some constant string';
  13.   S:=New(PDosStream,Init('test.dat',stcreate));
  14.   Writeln ('Writing "',L,'" to stream with handle ',S^.Handle);
  15.   S^.WriteStr(@L);
  16.   S^.Close;
  17.   Writeln ('Closed stream. File handle is ',S^.Handle);
  18.   S^.Open (stOpenRead);
  19.   P:=S^.ReadStr;
  20.   L:=P^;
  21.   DisposeStr(P);
  22.   Writeln ('Read "',L,'" from stream with handle ',S^.Handle);
  23.   S^.Close;
  24.   Dispose (S,Done);
  25. end.