Recent

Author Topic: TmemoryStream...  (Read 532 times)

cdbc

  • Hero Member
  • *****
  • Posts: 1026
    • http://www.cdbc.dk
TmemoryStream...
« on: July 02, 2020, 12:05:59 pm »
Hi
Right, so i've got this form, collecting data from user and populates a business object. One of the members is a TMemoryStream, that loads a file, all fine and dandy, but what happens when the user cancel in the midst?!? In short, i need to get rid of the data already loaded in the memorystream. Would this be a viable solution:
Code: Pascal  [Select][+][-]
  1. procedure TfrmEditBlob.btnCancelClick(Sender: TObject);
  2. begin
  3.   TMemoryStream(fBlob.Blob).SetSize(0);              // delete blob contents
  4.   fBlob.Blob.Position:= 0;
  5.   Close; // just forget everything
  6. end;
TIA - Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: TmemoryStream...
« Reply #1 on: July 02, 2020, 12:14:23 pm »
Memorystream.Clear

that keeps it alive still but empties it ..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018