Bzzzt. Warning. Create/Free detected without a try..finally.

Sorry uncontrollable Delphi reflexes kicked in. But you really should have a
try finally around that as follows:

function Matches(const S,Wildcard: String): Boolean;
var
  Mask: TMask;
begin
  Mask := TMask.Create(Wildcard);
  try
    Result := Mask.Matches(S);
  finally
    Mask.Free;
  end;
end;

Of course the best solution is to use the MatchesMask function from the
Masks unit as Stefan suggests...

David.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Ross Levis
> Sent: Tuesday, 1 July 2003 5:26 PM
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Wildcard match of strings
>
>
> Use the TMask object.  Here is a function I use.
>
> function Matches(const S,Wildcard: String): Boolean;
> var
>   Mask: TMask;
> begin
>   Mask := TMask.Create(Wildcard);
>   Result := Mask.Matches(S);
>   Mask.Free;
> end;
>
> Eg. If Matches('I am Roger',*Roger*) then...
>
> Ross Levis.
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to