Text lines into an array of unknown size

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

This is a multi-part message in MIME format.

------=_NextPart_000_0011_01C35DD5.0F2CD740
	charset="iso-8859-1"

as new commer from rexx to Euphoria I see many nice and semilare options =
and a richness of WinOS options but I have some
basic newcommer problems on 'sequence a array'=20

I want to open a file of text of unknown size and put all lines into an =
array where every line can be manipulated but I cannot get it right...

integer file
object line
constant ERROR =3D 2
integer c
c =3D 0
sequence tx

file =3D open("c:/rexx/rxcalibur.txt", "r")
if file =3D -1 then
 puts(ERROR, "couldn't open text file\n")
else
 while 1 do
  line =3D gets(file)
  if atom(line) then
   exit
  end if
 c =3D c + 1
 tx[c] =3D line
 end while
end if
close(file)=20
printf(1,"available lines:%d\n", {c}) -- correct
printf(1,"%s\n",tx[2]) -- ERROR=20

Where do I get it wrong!!! Probably a newcommers init problem but I =
would like some explane...

K=E5re Johansson
------=_NextPart_000_0011_01C35DD5.0F2CD740
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.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>as new commer from rexx to Euphoria I =
see many=20
nice&nbsp;and semilare options and a richness of WinOS options but I =
have=20
some</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>basic newcommer problems on 'sequence a =
array'=20
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to open a file of text of =
unknown size and=20
put&nbsp;all lines&nbsp;into an array where every line can be=20
manipulated&nbsp;but I cannot get it right...</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>integer file<BR>object line<BR>constant =
ERROR =3D=20
2<BR>integer c<BR>c =3D 0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sequence tx</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>file =3D open("c:/rexx/rxcalibur.txt", =
"r")<BR>if=20
file =3D -1 then<BR>&nbsp;puts(ERROR, "couldn't open text=20
file\n")<BR>else<BR>&nbsp;while 1 do<BR>&nbsp;&nbsp;line =3D=20
gets(file)<BR>&nbsp;&nbsp;if atom(line)=20
then<BR>&nbsp;&nbsp;&nbsp;exit<BR>&nbsp;&nbsp;end if<BR>&nbsp;c =3D c +=20
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;tx[c] =3D line<BR>&nbsp;end =
while<BR>end=20
if<BR>close(file) <BR>printf(1,"available lines:%d\n", {c})&nbsp;--=20
correct<BR>printf(1,"%s\n",tx[2]) -- ERROR </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Where do I get it wrong!!! =
</FONT>Probably a=20
newcommers init&nbsp;problem but I would like some explane...</DIV>
<DIV>&nbsp;</DIV>

------=_NextPart_000_0011_01C35DD5.0F2CD740--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu