read from file until a line begins with a certain word
Matthias Rebbe
matthias_livecode_150811 at m-r-d.de
Sun Sep 17 16:13:47 EDT 2017
Jacque,
thanks for that code sample. I was not aware that i can use EOF in a repeat loop as condition. I always thought that it only can be used in a read command like
read from file MyFile until EOF
Thanks again to all who gave feedback. It helped me a lot.
Regards,
Matthias
Matthias Rebbe
+49 5741 310000
wirmachen.software <http://wirmachen.software/>
> Am 17.09.2017 um 21:38 schrieb J. Landman Gay via use-livecode <use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>>:
>
> 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 <mailto:jacque at hyperactivesw.com>
> HyperActive Software | http://www.hyperactivesw.com <http://www.hyperactivesw.com/>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list