Community discussions

MikroTik App
 
pe1chl
Forum Guru
Forum Guru
Topic Author
Posts: 10223
Joined: Mon Jun 08, 2015 12:09 pm

Processing file line-by-line

Mon Jul 24, 2017 7:17 pm

I am writing a simple script that does a /tool fetch to fetch some URL and storing it in a file, resulting in a small file of textlines.
Fortunately the file is always (much) smaller than 4K, so I can then get it into a variable using [/file get "$name" contents].
This works OK, but I get the entire file contents in the variable.
Now I need to write some loop to process it line-by-line. Is there a clean example how to do this?
I have been looking for string manipulation functions like "split" that would split the variable into an array or list, but have
not found anything yet. Unfortunately the examples are all indexed by what they achieve, examples of programming
techniques are hard to find.

Who is online

Users browsing this forum: almdandi and 41 guests