Re: find/match not working

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:

> found = 0
> for loop = 1 to length(urllist) do
>   if match(junk,urllist[loop]) then
>      found = 1
>      exit
>    end if
>  end for
>  if not found then
>    urllist = urllist & {junk}
>   end if

When doing this sort of thing, I usually do this ...

 urltemp = upper(urllist)
 junk = trim(junk)
 found = find(upper(junk), urltemp)
 if not found then
    urllist = append(urllist, junk)
 end if

In other words, trim both data and do an case-insensitive search.

The find() function looks for a single element that exactly
matches the subject argument.

The match() function looks for a set of adjacent elements that
exactly matches all the elements in the subject argument.

To use match() in the way you have above might work better as ...

   if match(junk,urllist[loop]) = 1  and 
      length(junk) = length(urllist[loop]) then

in other words, ensure that if you get a match it starts
with the first character and is the same length. But that's
now equivalent to equal()! So it might be better to do ...

   if equal(junk,urllist[loop]) then

but if you are doing that, you may as well use find()
as it will work faster.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu