Page 1 of 1

Store list to file

Posted: 07 Apr 2014 11:52
by bichlepa
I tried to store a list to a file in order to read it later again. But after getting the file content into variable it is not recognized as a list anymore.

Example flow:
http://automagic4android.com/flow.php?i ... ca11440a0e
On first run it creates a list and stores it to file. On second run it reads the file and tries to extract a value from list.

Re: Store list to file

Posted: 10 Apr 2014 09:05
by Martin
Reading a text file simply fills a variable with the textual content, converting to a list is something that has to be done manually in a script.
Something like this should work when saving a simple list:
-action Write to File: {list,listformat}
This creates a text file that contains each list entry on a separate line.

Then you can read the text file back into a variable as a string:
-action Init Variable Text File: file.txt to file_text
and convert it into a list:
-action Script: list = split(file_text, "\n");

When the list contains more complicated elements like other lists or locations, you would have to create a more sophisticated flow to also convert each element of the list appropriately back from text to the real type.