Write data to a file

writedata collection name

Writes the collection (list, array or dictionary) to a text file with the name. Each successive item from the collection is written in the new line. If an item is a collection then the corresponding text line is equal to the output of the print instruction for this item, except the opening and closing brackets.

If the name does not contain an absolute path then the file is created in the current directory, as defined in the :pool_cfg,"current_dir variable.

Example:

"k := {abc 123 x y z}
writedata :k "array1.txt

"m := readarray "array1.txt
print :m

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

"n := readarray "array2.txt
print :n

Output:
(also compare the content of the "array1.txt" and "array2.txt" files)

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

See also:

Array

Table of Content