RE: Newbie Question
- Posted by rforno at tutopia.com Apr 27, 2001
- 418 views
Please, tell me where can I get strtok.e Thanks. ----- Original Message ----- From: Kat <gertie at PELL.NET> Subject: RE: Newbie Question > > > On 25 Apr 2001, at 22:00, rforno at tutopia.com wrote: > > > > > > > > ----- Original Message ----- > > From: Travis Beaty <travisbeaty at arn.net> > > To: EUforum <EUforum at topica.com> > > Sent: Wednesday, April 25, 2001 3:11 PM > > Subject: Re: Newbie Question > > > > > > > > > > > > > Howdy! > > > > > > > > > tpopel at yahoo.com wrote: > > > > > > > I have to do some work with 2 dimensional, comma > > > > delimited text files. > > > > > > > > Is this the kind of thing Euphoria does well? > > > > > > Very well, for numerous reasons! > > > > > > > What replaces the old input# statement from basic? > > > > > > Wow, that was a *long* time ago. Somebody back me up on this, but I > > > believe that you are looking for the Euphoria function gets(). So, > > > you'd do something like this ... > > > > > > integer > > > FileId > > > > > > object > > > data > > > > > > FileId = open("mydata.txt", "r") > > > data = gets(FileId) > > > ... > > > close(FileId) > > > > > > -- Travis -- > > > > > > > > > > This does not solve the problem. gets() only gets one line (up to \n) from > > the file, but does not separate the items as delimited by commas. After > > that, you should use the value() function. > > But value() has a shortcoming: after getting the first numerical item up to the > > following space or comma (or any non-numerical character), it does not show the > > point up to which it got. What Euphoria needs is a function, similar to value(), > <snip> > > Strtok.e has: > gettok() to get the data tween the commas > toknum() to count the data tween the commas > gettok() to get the data item you specify > instok() to put a data item in tween commas > deltok(),, well, you get it > reptok() replace a certain data field > parse() to return the data items in gets() as sequences > deparse() to make a nested seq into a sentence or comma delinited string or > whatever. > etc > > and you can spec as delimiters a comma, semicolon, or any other one-byte > char. If you pass gettok() a paragraph with sentences delimited with ascii 10, > use gettok(paragraph,10). To get words out of the sentence, use a ' ' or 32. > at least i think i updated that before sending it in to RDS, make all the "char > c" in the functions into "integer c".) Also, empty data fields in a comma > delimited line may not be parsed properly, so comment out these lines in > parse(): > > -- doublec = c & c > -- while match(doublec,s) do > -- s = s[1..match(doublec,s)] & s[match(doublec,s)+2..length(s)] > -- end while > > Kat > > > > >