Read list from a file

readlist name

Reads in and returns a list from a file with the specified name. Each line in the file becomes an item in the list. Empty lines are omitted. If a line consists of multiple words (separated with white spaces then) a sublist of words is created and added as an item to the list. If at least one item in the list is a sublist then all other items which are not yet lists are converted to single-item lists.

If the name does not contain an absolute path then the file is assumed to be in the current directory, specified with the :pool_cfg,"current_dir variable.

The name can be also a http adress.


"k := [abc 123 x y z]
writedata :k "list1.txt

"m := readlist "list1.txt
print :m

"l := [123 abc [a [b c]] {x y z}]
writedata :l "list2.txt

"n := readlist "list2.txt
print :n


[abc 123 x y z]
[[123] [abc] [a [b c]] [x y z]]

See also:


Table of Content