Config File read/write

by Mark C

Version 1 (February 2, 2016)

Download (1,326 downloads)

Use in your flows to create and read a configuration file.

*Updated version: it is now possible to store and retrieve Dictionary and Array variables in the Config Dictionary Variable ( but they cannot be nested!). This version was NOT created with an alpha version of Automate (sorry about that).

Config file is plain text with each line being of the form:



-ArrayItem=1, 2, 3, a, b, c
+DictionaryItem=1: 100, 2: 200, Three: Three Hundred

Format is a bit strict, no spaces between itemname=value but value can contain anything except an "=" character. No blank lines in the file. Values in Dictionary items cannot contain the ":" character and values in Array items cannot contain a "," (comma) character. You can get round this by changing the delimiters used when writing/reading the file.

To test, set variable "ConfigFile" to the path you want (default is "myconfig" on root of internal storage) and run the Flow. If no config file exists then an example is created, if a file exists then it is read into a Dictionary called "Config".

You should have no trouble using this example in your own flows: to read your config file just enter at " file exists" and to update the file (once you have the "Config" Dictionary filled) enter at "File Delete"

Access your config settings as: setting=Config[] EG. email=Config["Email"]

Change settings with Dictionary Put blocks.

4.2 average rating from 5 reviews

5 stars
4 stars
3 stars
2 stars
1 star

Rate and review within the app in the Community section.