read from file until a line begins with a certain word

J. Landman Gay jacque at hyperactivesw.com
Sun Sep 17 15:38:36 EDT 2017


On 9/17/17 8:18 AM, Paul Dupuis via use-livecode wrote:
> concatenating a cr (or whatever line delimiter the file uses if opening
> as binary) before mStart and reading from file until that string will
> find all instances but the 1st line of the file (it the file starts with
> mstart)

I think it should find the first line as well:

on parseFile
   put "/path/to/file" into tFile
   put cr & "mstart" into tDelim
   open file tFile for read
   repeat until eof
     read from file tFile until tDelim
     -- process the text here
   end repeat
end parseFile

The only hitch is that the last word of the retrieved text will be 
"mstart" preceded by a cr. But it wouldn't be hard to delete that and 
add it before the next retrieval, since the delimiter is a constant.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list