Saving parameters to User Defaults
Hi all,
is there any way of saving single parameters (like e.g. the content of a text box) to some kind of user defaults?
I mean, if a user changes a parameter it should be automatically saved somewhere with no file prompt or anything related.
Thanks in advance
yes sure ! , please take a look at the [pattr] object family . have fun !
Thanks for the reply, I already did look at the pattr / pattrstorage stuff. My patch will run in standalone mode - the autorestore features of the pattr family only seem to work if the concerning patcher is saved. I'm honestly a bit confused by the documentation..
yes , it will recall the state after running the patcher . is it what you desired ? . you can alternatively use [coll] or [dict] and "embed" em to the patcher . you will be able to provide your own preset logic too ,do defaults or whatever else . but as i said you need to implement system that hits your controls while certain conditions are fulfilled (on loadbang or whenever you want) .
Yep, that's what I want to achieve. But the internal state only seems to be saved if I save my patcher document. If I compile my patch and run it as a standalone application (or just run the patch in non-edit mode) the [pattr] object doesn't seem to overwrite the states.
yes because you need to save your changes. it wont remember if you did not saved it . this would be destructive in some cases .
but if you will look at the [pattrstorage] help file , you will find that SAVE section ,there you can find how to autosave settings to a file . you can force your patch to rely on that stored file . perhaps it should work for you
If you're working in Max 6, have you considered clicking on "Parameter Mode Enable" in the Inspector for your UI object and then checking the "Initial Enable" checkbox which then appears and typing in a value in the "Initial" space directly below it in the Inspector?
i suppose that OP wants to save last changes without resaving the patcher .
Ah. They want the *last* setting. Then it's most definitively savemode in pattr.
Sorry maybe it helps to describe the concrete Use-Case. In my patch there is a textbox which displays the current port for incoming OSC messages. If a user types in a different port, the patch should replace its internal setting - if possible without writing a new .xml file for this single value. And yes, without re-saving the patcher because it will be compiled as a standalone application.
My question was, if Max has some sort of "User defaults" feature to store certain parameters internally.
What would be wrong with taking the output of a UI object and using an ordinary message box to store whatever value a user types in (via a set message to the right inlet) which could then be triggered with a loadbang object (for outputting the value the next time the app is launched)? It's not exactly rocket surgery, but....
...but to store the message the patch still needs to be saved (?)
Oh, right. No way to do it that I can think of, then. Oh - but this isn't just an ordinary standalone, is it? You're thinking App Store, I suppose. D'oh! Sorry - time for coffee!
I apologize if I was a bit vague with the message box solution [love those backchannel email things]. While it won't help kraftwerk any, here's a simple example *will* save initial states or states a user changes and fire up with that setting next time [of course, you'll need to save the program]....
oh coffee , i forgot ,its cold now .
@kraft . check this
edit : read is connected now
Elegant read/writes on the fly!
@ gregory : thanks :)
@kraft : if you like this solution ,you can use [thispatcher] to retrieve current patch path to store the file where your patcher is placed
Thanks, looks good. [thispatcher] doesn't seem to work properly if you use it in a Max-standalone application - here is a workaround that I also found somewhere in the forum a while ago:
oh it is a wrong patch , please repost the code
I guess you can do it with coll but that seems cumbersome if you want to store multiple variables....
Why not just use [preset]? I mean, that's what it's there for, no? :)
The idea is this, on patch close you use a [closebang] to do -
- send a "store 1" message to [preset] to save current values
- then send a "write (path)/usersettings.maxpresets" to [preset] to save to disk
Then on patch open you use [loadbang] to:
- send a "read (path)/usersettings.maxpresets" to [preset]
- send a "1" to recall the preset slot.
On Mac, it's ideal to read/write to Macintosh HD/Users/Shared to avoid permissions problems.
On Windows, you can write to "C:Documents and SettingsAll UsersApplication Data". On XP at least... later versions of Windows are slightly different paths, I think.
Hope this helps!
Sorry I just re-posted your patch @KrisW. Here is what I meant to post:
Thanks misho this looks like a convenient solution!