I'm writing a little tool to do some variable conversion for Matrix. Taking care of the regular skin settings is no problem - my UI code has correction routines going back almost to version 1, and those all work just fine. In this case, however, what I need to alter are some folder-specific settings, which are stashed in the folder/.info files.
So, the tools traverses the project tree, and when it encounters a folder, it looks for the old variables and, if they're not empty, strings them together into a new variable:
The best way forward is to modify the .info files via the AlbumObjectProperties API and not modify the .info files directly. If you have problems with any part of this, let me know and I'll provide an example.
That's what I've been trying to do. A put() doesn't produce any errors, but the results don't land in the .info file, either, and for subsequent album builds, they need to be there. I'm obviously missing some piece of this puzzle.
And to clarify, this isn't something that would execute during project loading, or during album building. It's a one-shot, "fix this old project" tool.
Through trial and error, I'm getting closer. This actually does add the desired variable to the vars for the ao:
And a vars.remove(name) has the desired effect.
Now how do I save them? And at this point, the vars includes all the stuff from the project settings, as well as the folder-specific .info variables. Clearly, I don't want to write all of those out to the info file.
Ah, you're correct, so I was puzzled by the lack of null pointer errors in my early testing. I could ao.getVars().get("someVar") even when someVar wasn't present in the .info file, and check it for emptiness, with no problem.
Turns out that if the variable has a default value in SlideModel.java, that's what you get when you ask for ao.getVars().get("definedVar"), even when that variable isn't called out in .info. But that doesn't apply when you're grabbing ao.getProperties().get("definedVar"). In that context, you get a null if definedVar isn't present in .info - no default value is present.