Re: HELP!!!
- Posted by Bryan Melugin <bmelugin at BELLSOUTH.NET> Jul 23, 1999
- 450 views
By The Way, The Text file contains more than one record. There are 40 records in this file which means there are 40 ST and 40 SE all in the same file. Thats why I'm trying to pull them out into their own file. Bryan JJProg at CYBERBURY.NET wrote: > EU>I'm new to Euphoria and have gone through the tutorial. My question > EU>will be easily answered by any one of you Euphoria Guru's out there. > EU>Here it goes. Can someone tell me how to pull information from a text > EU>file which includes only the information between two lines. Say I have > EU>a line that starts with ST and then there are 40 lines down and then > EU>there is a line that starts with SE. If I want just the info between ST > EU>and SE and put it into a different text file, can that be done? Any > EU>help would be greatly appreciated. I have been working on this for 3 > EU>days now and I've almost given up hope. > EU>Thanks again > > EU>Bryan > > Try this: > > constant START = "ST\n" -- gets returns a new line character at the end > -- of a line > constant END = "SE\n" > sequence line, data > integer f > f = open("infile.txt","r") > line = gets(f) > while not equal(line,START) do -- Skip all data before and including > -- START > line = gets(f) > end while > data = "" > line = gets(f) > while not equal(line,END) do -- Get all the data up to END > data &= line > line = gets(f) > end while > close(f) > f = open("outfile.txt","w") > puts(f,data) -- Write the data to the output file > close(f) > > Jeffrey Fielding > JJProg at cyberbury.net > http://members.tripod.com/~JJProg/