Continuing the discussion from [KM] DELETE List of KM Variables [SUB-MACRO]:
I started a new topic for this.
I've regularly wished there was some sort of Name/Value storage system available to KM. It would be awesome if someone could produce a generic version of this.
But since that isn't available (to my knowledge), I'm going to give you one answer, but I can guarantee that someone else will come up with a better idea. Always happens when I reply to something like this. And honestly, I hope they do, because this isn't the most elegant solution.
The answer depends a lot on two questions:
- How bullet-proof does this need to be? Are you the only one who's going to use it? Are you OK with fixing issues as they come up?
If we assume the answer to #1 is that you're using it for yourself, and if it breaks, you'll fix it, then let's go on to #2.
- What kind of data will you be storing?
a) For example, if each of your variables can be guaranteed to be a single line, then you could write them out to a text file, one value on each line. When you read the file back in, you'd have to make sure you "got the variables out" in the same order you put them in.
This isn't very bullet-proof. For example, if you no longer need a particular variable, you'd still need to continue to read it and write it back out. New variables would always have to be added to the end. And if a stray NEWLINE got introduced into a variable somehow, everything breaks.
b) I have one workflow where I store various settings, each in their own file, inside folders for each "preset". This is pretty easy. I do it this way in this particular workflow, because many of the variables are lists, so it's a lot easier to deal with one file per variable.
c) Another idea is, you could develop some JSON objects and use JXA to store and retrieve them. I know this is possible, I don't know how to do it myself, but there are some examples embedded in various macros and plugins on the forum.
That's all I got. Interested to see what comes of this topic. I know I'll learn something new - I always do!