Difference between revisions of "Talk:Lazarus Tdbf Tutorial"

From Free Pascal wiki
Jump to navigationJump to search
 
Line 22: Line 22:
 
   MyDbf := TDbf.Create(nil);
 
   MyDbf := TDbf.Create(nil);
 
   try
 
   try
  //etc.
+
    { use relative path to "data" directory }
 +
    //etc.
 +
 
 
</code>
 
</code>

Revision as of 23:07, 23 March 2005

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
   { use relative path to "data" directory }
   //etc.