> I must be missing something really simple here.
>
> This is designed to test the ReadConfFile proc I've written - it should
> bring up a message dialog with the error "file not found" in it, but nothing
> comes up and the form closes as it normally would.
>
> procedure Tmenu.FormDestroy(Sender: TObject);
> var
> Temp: TStringList;
> begin
> Temp := TStringList.Create;
> Temp := General_bits.ReadConfFile('ljch');
> if Temp = Nil then
> begin
> MessageDlg(General_bits.Last_Error, mtError, [mbok], 0);
> end
> else begin
> Temp.SaveToFile('c:\windows\desktop\blah.txt');
> end;
> end;
1. Are you 'Destroying' the form via 'Free' or 'Release' or are you just 'Closing' the
form.
2. Temp is assigned a new TstringList and then that TStringList is abandoned
without being freed.
3. Does General_Bits.ReadConfFile(String) capture the exception itself?
4. The TStringList returned from General_Bits.ReadConfFile(String) does not get Freed.
Corrected format.
// If General_Bits.ReadConfFile(String) creates a TStrings.
var
Temp :TStrings;
begin
Temp := General_Bits.ReadConfFile('ljch');
if Temp=nil then
MessageDialog(General_bits.Last_Error, mtError, [mbok], 0)
else try
Temp.SaveToFile('c:\windows\desktop\blah.txt');
Temp.Free;
finally
Temp.Free;
end;
end;
// If General_Bits.ReadConfFile(String) places results in a precreated TStrings.
var
Temp :TStrings;
begin
Temp := TStringList.Create;
try
if General_Bits.ReadConfFile('ljch',Temp) then
Temp.SaveToFile('c:\windows\desktop\blah.txt');
else
MessageDialog(General_bits.Last_Error, mtError, [mbok], 0);
finally
Temp.Free;
end;
end;
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz