Re: my dilemma -- hundreds of record types

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

On 15 Nov 2002, at 13:30, Chris Saik wrote:

> 
> <snip>
> 
> > 
> > Kat wrote:
> > 
> > > Use gets() to read the file into a sequence, and
> > then a simple loop thru
> > > the sequence, to find the tags you are looking
> > for.
> > 
> > Almost:)  gets() reads one line up to the c/r from a
> > file. In order to get an 
> > entire file, which you might as well do if the files
> > aren't really huge:
> > 
> > -- (tested)
> > atom fn
> > object line, text
> > 
> > fn = open("test.txt","r")
> > 
> > text = {}  -- start with empty buffer
> > while 1 do  -- loop forever
> >   line = gets(fn) -- read a line
> >   if atom(line) then exit -- get out of the forever
> > loop!
> >   else text = append(text,line) -- add line to
> > buffer
> >   end if
> > end while
> > 
> > for i = 1 to length(text) do -- iterate thru the
> > buffer
> >   if match("<YEAR>",text[i]) then -- looking for the
> > <YEAR> tag
> >      puts(1,text[i])  -- if tag is found, print the
> > entire line
> >   end if
> > end for
> 
> Thank you Irv.  I'm confused over one thing though...
> what if the data following the tag is several lines
> long, as in a paragraph?  How would I print the entire
> data within the field, and stop when the program
> reaches the next tag? 

Yeas Irv, can you do it as easily as gets(), without using gets() ?

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu