ex14.pp 578 B

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