ex19.pp 578 B

123456789101112131415161718192021222324252627
  1. Program ex19;
  2. { Program to demonstrate the TStream.CopyFrom function }
  3. Uses objects;
  4. Var P : PString;
  5. L : String;
  6. S1,S2 : PStream;
  7. begin
  8. L:='Constant string line';
  9. Writeln ('Writing to stream 1 : "',L,'"');
  10. S1:=New(PMemoryStream,Init(100,10));
  11. S2:=New(PMemoryStream,Init(100,10));
  12. S1^.WriteStr(@L);
  13. S1^.Seek(0);
  14. Writeln ('Copying contents of stream 1 to stream 2');
  15. S2^.Copyfrom(S1^,S1^.GetSize);
  16. S2^.Seek(0);
  17. P:=S2^.ReadStr;
  18. L:=P^;
  19. DisposeStr(P);
  20. Dispose (S1,Done);
  21. Dispose (S2,Done);
  22. Writeln ('Read from stream 2 : "',L,'"');
  23. end.