Compare question
- Posted by sixs at ida.net Sep 20, 2003
- 424 views
This is a multi-part message in MIME format. ------=_NextPart_000_001D_01C37F91.9FDE7E50 charset="iso-8859-1" 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 =3D=3D> if compare( "<", line[i]) =3D 0 and compare(line[i+1], "t") =3D 0 and=20 compare(line[i+2], "d") =3D 0 =20 then puts(1, line) -- output is: ABC Jim =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D code follows sequence buffer object line integer fn trace(1) -- read a text file into a sequence fn =3D open("te.html", "r") if fn =3D -1 then puts(1, "Couldn't open myfile.txt\n") abort(1) end if buffer =3D {} while 1 do line =3D gets(fn) for i =3D 1 to length(line) do printf(1, "%s", {line[i]}) -- correct puts(1, line[i]) puts(1, lessThan) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D if compare( "<", line[i]) =3D 0 and compare(line[i+1], "t") =3D 0 and=20 compare(line[i+2], "d") =3D 0 =20 then puts(1, line) -- output is: ABC buffer =3D append(buffer, line)=20 end if =20 if atom(line) then exit -- -1 is returned at end of file end if end for puts(1, line) -- output is: ABC =20 end while exit ------=_NextPart_000_001D_01C37F91.9FDE7E50 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2730.1700" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I am trying to compare a value first = position in a=20 html file. This position contains "<" with a this next = line of=20 code</FONT></DIV> <DIV> <FONT face=3DArial size=3D2>This is supposed to be an equal = compare for=20 the very first position</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =3D=3D> if compare( "<", = line[i]) =3D 0=20 and<BR> compare(line[i+1], "t") =3D 0 and=20 <BR> compare(line[i+2], "d") =3D = 0 =20 <BR> = then<BR> puts(1,=20 line) -- output is: ABC</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Jim</FONT></DIV> <DIV><BR><FONT face=3DArial = size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FO= NT></DIV> <DIV><FONT face=3DArial size=3D2>code follows</FONT></DIV> <DIV><FONT face=3DArial size=3D2>sequence buffer<BR>object = line<BR>integer=20 fn<BR>trace(1)<BR>-- read a text file into a sequence<BR>fn =3D = open("te.html",=20 "r")<BR>if fn =3D -1 then<BR> puts(1, "Couldn't open=20 myfile.txt\n")<BR> abort(1)<BR>end if</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>buffer =3D {}<BR>while 1 = do<BR> line =3D=20 gets(fn)<BR> for i =3D 1 to length(line) = do<BR> printf(1, "%s",=20 {line[i]}) -- correct<BR> puts(1,=20 line[i])<BR> puts(1, lessThan)</FONT></DIV> <DIV><FONT face=3DArial = size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR> if=20 compare( "<", line[i]) =3D 0 and<BR> = compare(line[i+1],=20 "t") =3D 0 and <BR> = compare(line[i+2], "d") =3D=20 0 <BR> =20 then<BR> puts(1, line) -- = output=20 is: ABC<BR> buffer =3D append(buffer, = line)=20 <BR> end if<BR> <BR> if atom(line)=20 then<BR> exit -- -1 is returned at end of=20 file<BR> end if<BR> end for<BR> puts(1, = line) =20 -- output is: ABC</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> <BR>end=20 ------=_NextPart_000_001D_01C37F91.9FDE7E50--