TMemoryStream.Truncate procedure
Set the stream size to the current position.
Declaration
procedure Truncate; virtualDescription
Truncate sets the size of the memory stream equal to the current
position. It de-allocates any memory-blocks that are no longer needed, so
that the new size of the stream is the current position in the stream,
rounded up to the first multiple of the stream blocksize.Errors
If an error occurs during memory de-allocation, the stream's status is set
to
stError
See also
Example: ex20
Program ex20;
{ Program to demonstrate the TMemoryStream.Truncate method }
Uses Objects;
Var L : String;
P : PString;
S : PMemoryStream;
I : Longint;
begin
L:='Some constant string';
{ Buffer size of 100 }
S:=New(PMemoryStream,Init(1000,100));
Writeln ('Writing 100 times "',L,'" to stream.');
For I:=1 to 100 do
S^.WriteStr(@L);
Writeln ('Finished.');
S^.Seek(100);
S^.Truncate;
Writeln ('Truncated at byte 100.');
Dispose (S,Done);
Writeln ('Finished.');
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
