pattrstorage issues and autorestore strategies
%#%## First of all, I'm confused by the autorestore attribute of pattrstorage.
I have [pattrstorage midiconf @autorestore 0] but when I open the patch, it DOES automatically load a midiconf.xml file and restore the values.
As a workaround I do put the @autorestore 0 into each and every [pattr] object, but the autorestore attribute is also listed in pattrstorage's reference file, so I assume that it should work.
%#%## Second thing is issue with paths. In order not to confuse the pattrstorage object, I don't specify ANY paths to it. When I tell it to "writexml midiconf" it does write it where he wants and I never manually saved it anywhere else.
Thing is, that when that (unwanted) autorestore happens, I always find this error message in MAX window:
"Multiple files named midiconf.xml were found in the project folder (this one in data). Please remove or rename any unused copies."
So I look it up, and there is one file in main project directory and in data directory. So I deleted both, reopen the patch, play with it, but next time I am getting the same error message again... How is this possible?
here is the part of the patch:
Here are some places I'd look if I had this problem:
--Are you using [autopattr]? if so, note that its @autorestore attribute is "1" by default
--try giving the pattrstorage an @savemode attribute (maybe you want "@savemode 3"?) instead of sending a "writexml" message on close.
--"writeagain" may be better than "writexml." the "write" message overwrites the existing file (I think). Writeagain is like command-S.
--Delete any unwanted "midiconf.xml" files from the hard drive (not just the max project interface)
--Go to Project Settings>Project Inspector and look into using "Always Localize Project Items;" Also check to see whether you are using "local" or "global" project files (see the "About Projects" vignette)
--Put [deferlow] before all messages to [pattrstorage]
--Specify the location of your .xml file in the "data" folder of the project.
--Use [pipe] and [delay] to spread out slot and write messages to [pattrstorage]. here's an example:
Have fun!
thanks!
- i'm not using autopattr
please, could you describe how to "specify the location of your .xml file in the "data" folder of the project"? (without java please)
I mean, the project should know it's absolute path, so I use only relative paths.
Do you mean something like "writexml data\\midiconf.xml" and "read data\\midiconf.xml" ?
i'll check the rest of the hints too. thanks a lot!!
Easy to specify location. Send [pattrstorage] a "write" message (no filename arguments; just "write") and save the .xml in the "data" folder of the project. If the project has no "data" folder create it (lowercase).
Tip; make sure you're saving into the current project hierarchy. Sometimes the save prompt initializes elsewhere.
Hi,
got an issue too with autorestore.
As written in the reference page of pattrstorage with "autorestore 1", I want the last-saved file to reload when opening my patch.
with max 6, the patch only try to reload a json file with the name of the pattrstorage
with max 5, it only reload the first saved file ever.
is there something I'm missing ?
thank's a lot