Compare question

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

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 "&lt;"&nbsp; &nbsp; with a this next =
line of=20
code</FONT></DIV>
<DIV>&nbsp;<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>&nbsp;=3D=3D&gt; if compare( "&lt;", =
line[i]) =3D 0=20
and<BR>&nbsp;&nbsp;&nbsp;&nbsp; compare(line[i+1], "t") =3D 0 and=20
<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; compare(line[i+2], "d") =3D =
0&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts(1,=20
line)&nbsp;&nbsp; -- output is:&nbsp; ABC</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;puts(1, "Couldn't open=20
myfile.txt\n")<BR>&nbsp;abort(1)<BR>end if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>buffer =3D {}<BR>while 1 =
do<BR>&nbsp;line =3D=20
gets(fn)<BR>&nbsp;for i =3D 1 to length(line) =
do<BR>&nbsp;&nbsp;printf(1, "%s",=20
{line[i]})&nbsp;&nbsp; -- correct<BR>&nbsp;&nbsp;&nbsp;puts(1,=20
line[i])<BR>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;if=20
compare( "&lt;", line[i]) =3D 0 and<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
compare(line[i+1],=20
"t") =3D 0 and <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
compare(line[i+2], "d") =3D=20
0&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts(1, line)&nbsp;&nbsp; -- =
output=20
is:&nbsp; ABC<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer =3D append(buffer, =
line)=20
<BR>&nbsp;&nbsp;end if<BR>&nbsp;<BR>&nbsp;if atom(line)=20
then<BR>&nbsp;&nbsp;exit&nbsp;&nbsp; -- -1 is returned at end of=20
file<BR>&nbsp;end if<BR>&nbsp;end for<BR>&nbsp;&nbsp;puts(1, =
line)&nbsp;&nbsp;=20
-- output is:&nbsp; ABC</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;<BR>end=20

------=_NextPart_000_001D_01C37F91.9FDE7E50--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu