Saving parameters to User Defaults

    Nov 30 2012 | 10:59 am
    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

    • Nov 30 2012 | 11:02 am
      yes sure ! , please take a look at the [pattr] object family . have fun !
    • Nov 30 2012 | 11:35 am
      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..
    • Nov 30 2012 | 11:51 am
      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) .
    • Nov 30 2012 | 1:14 pm
      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.
    • Nov 30 2012 | 1:33 pm
      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
    • Nov 30 2012 | 1:56 pm
      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?
    • Nov 30 2012 | 2:01 pm
      i suppose that OP wants to save last changes without resaving the patcher .
    • Nov 30 2012 | 2:26 pm
      Ah. They want the *last* setting. Then it's most definitively savemode in pattr.
    • Nov 30 2012 | 2:40 pm
      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.
    • Nov 30 2012 | 3:13 pm
      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....
    • Nov 30 2012 | 3:31 pm
      ...but to store the message the patch still needs to be saved (?)
    • Nov 30 2012 | 3:51 pm
      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!
    • Nov 30 2012 | 3:58 pm
      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]....
    • Nov 30 2012 | 4:06 pm
      oh coffee , i forgot ,its cold now .
      @kraft . check this
      edit : read is connected now
    • Nov 30 2012 | 4:36 pm
      Elegant read/writes on the fly!
    • Nov 30 2012 | 4:41 pm
      @ 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
    • Nov 30 2012 | 5:12 pm
      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:
    • Nov 30 2012 | 5:17 pm
      oh it is a wrong patch , please repost the code
    • Nov 30 2012 | 7:40 pm
      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!
    • Dec 03 2012 | 8:52 am
      Sorry I just re-posted your patch @KrisW. Here is what I meant to post:
    • Dec 03 2012 | 9:00 am
      Thanks misho this looks like a convenient solution!