Re: my dilemma -- hundreds of record types
- Posted by Chris Saik <csaik2002 at yahoo.com> Nov 15, 2002
- 450 views
<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? Thanks for your assistance, Chris