Re: Compare question

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

Lucius L. Hilley III
----- Original Message ----- 
From: "Pete Lomax" <petelomax at blueyonder.co.uk>
To: "EUforum" <EUforum at topica.com>
Subject: Re: Compare question


>
>
> On Sat, 20 Sep 2003 16:09:52 -0600, sixs at ida.net wrote:
>
> >
> >I am trying to compare a value first position in a html file. This
position contains "<"    with a this next line of code
> > This is supposed to be an equal compare for the very first position
> > ==> if compare( "<", line[i]) = 0 and
> try compare('<',line[i]).
>
> line is going to be "<td.., so line[1] is a character, not a string.
> You don't need compare in this case, using line[i]='<' is fine.
>
> Pete
>

And to expand on that.
Correcting your code becomes:
if compare( '<', line[i]) = 0 and
     compare(line[i+1], 't') = 0 and
        compare(line[i+2], 'd') = 0
      then
     puts(1, line)   -- output is:  ABC

and is the same as:

if compare(">td", line[i..i+2]) = 0 then
  puts(1, line) -- output is: ABC
end if

You can also use: equal(">td", line[i..i+2])

        Lucius L. Hilley III - Unkmar
        Senior EXaminer - SEX <big grin>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu