Board index » delphi » Try....Finally..end Query

Try....Finally..end Query

Which is best and why ?
1.
   try
     CredSearch := TCredSearch.Create(Self);
     CredSearch.ShowModal;
  finally
      CredSearch.Release;
  end;

2.
 try
     CredSearch := TCredSearch.Create(Self);
     CredSearch.ShowModal;
  finally
     CredSearch.Free;
     CredSearch := Nil;
  end;

Thanks,

Chris
ChrisRoss....@EggConnect.net

 

Re:Try....Finally..end Query


Quote
>      CredSearch.Free;

is all you need to free the form.  Setting it to nil is to avoid having to
check Assigned prior to your create statement.

Paul / ColumbuSoft
www.columbusoft.com

Quote
chrisross.arc <chrisross....@eggconnect.net> wrote in message

news:39dc3b42_2@dnews...
Quote
> Which is best and why ?
> 1.
>    try
>      CredSearch := TCredSearch.Create(Self);
>      CredSearch.ShowModal;
>   finally
>       CredSearch.Release;
>   end;

> 2.
>  try
>      CredSearch := TCredSearch.Create(Self);
>      CredSearch.ShowModal;
>   finally
>      CredSearch.Free;
>      CredSearch := Nil;
>   end;

> Thanks,

> Chris
> ChrisRoss....@EggConnect.net

Re:Try....Finally..end Query


Quote
chrisross.arc wrote:
> Which is best and why ?
> 1.
>    try
>      CredSearch := TCredSearch.Create(Self);

This line should be before the "try".

--
David Marcus

Other Threads