Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
As I know nothing really of freeing memory (other than I have tried to be methodical and release everything I use)
saveDialog := TSaveDialog.Create(self);
saveDialog.Title := 'Choose name to save as';
saveDialog.InitialDir := RootDir + '/logs';
saveDialog.Filter := 'log files (*.ybb)|*.ybb';
saveDialog.DefaultExt := 'ybb';
saveDialog.FilterIndex := 1; starting filter type
if saveDialog.Execute
then
begin
MyFilename := ExtractFileName (saveDialog.FileName);
end
else
begin
ShowMessagePos('Please enter a filename to save the log',(Self{MainForm}.Width Div 2) + Self{MainForm}.Left - 80,(Self{MainForm}.Height Div 2) + Self{MainForm}.Top - 50);
exit;
end;
saveDialog.Free;
function NotGood;
var StrList : TStringList;
begin
StrList := TStringList.Create;
StrList[1] := 'BOOM!'
FreeAndNil(StrList);
end;
function BetterButStillNotGood;
var StrList : TStringList;
begin
try
StrList := TStringList.Create;
StrList[1] := 'BOOM!'
finally
FreeAndNil(StrList);
end;
end;
function Good;
var StrList : TStringList;
begin
StrList := TStringList.Create;
try
StrList[1] := 'BOOM!'
finally
FreeAndNil(StrList);
end;
end;
you can leave it in the compiled exe. the DebugHook <> 0; statement will only be true when you run the program under delphi.from my project dpr when I have finished writing it, or can I leave there with no effect on the compiled exe?
unit StringListInterface;
interface
uses
SysUtils,
Classes,
SyncObjs;
type
IIStringList = interface
['{344B711B-FBB2-473B-A864-F5D0ABB7A8F8}']
function List : TStringList;
end;
TIStringList = class(TInterfacedObject, IIStringList )
public
StringList : TStringList;
function List : TStringList;
constructor Create;
destructor Destroy; override;
end;
implementation
constructor TIStringList .Create;
begin
StringList := TStringList.Create;
end;
destructor TIStringList .Destroy;
begin
FreeAndNil(StringList);
inherited;
end;
function TIStringList .List : TStringList;
begin
Result := StringList;
end;
end.
uses StringListInterface;
procedure TestStringListInterface;
var IStringList : IIStringList;
begin
IStringList := TIStringList.Create;
IStringList.List.Add('test');
end;
uses StringListInterface;
procedure TestStringListInterface;
var IStringList : IIStringList;
StringList : TStringList;
begin
IStringList := TIStringList.Create;
StringList := IStringList.List;
StringList.Add('this works');
IStringList := nil; // this will call the destructor
StringList.Add('this will generate an AV'); //Stringlist points to and object that no longer exists
end;
Where does the hex number come from, out of interest?