Talk:Lazarus Tdbf Tutorial

From Free Pascal wiki
Revision as of 23:06, 23 March 2005 by Matthijs (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The following code var

 MyDbf: TDbf;

begin

 try
   MyDbf := TDbf.Create(nil);
   { use relative path to "data" directory }
   // etc ..
   MyDbf.Close;
 finally
   MyDbf.Free;
 end;

end; should have the Create statement outsite of the try .. finally construct. Because when something goes wrong with the creation what has been created will be automatically freed. (At least this way it is in Delphi) So I would advise to change to code to var

 MyDbf: TDbf;

begin

 MyDbf := TDbf.Create(nil);
 try
 //etc.