How to use pattr to save coll data

    Dec 25 2011 | 8:26 pm
    Maybe I've eaten too much today (happy holidays everyone) but it is beyond me to figure out how to use the pattr system to save the contents of coll or even if that's the right way to do it. I'm not in a position yet to move to max6 so can't use the dict stuff. SQLite seems like overkill for this problem.
    Before everyone suggests that I just set the coll to store data with patcher, the problem is that the maniupulations I want to do require that the coll (and associated operations) live in an abstraction that I can just instantiate in lots of other patchers (typically only one of which main patcher would be open at a time)
    Other patchers that are open all the time would be communicating with the instatiated abstraction in whatever main patcher is open to copy data in either direction.
    To provide context, I have a "front panel" that represents a collection of control surfaces. Each main patcher represents a particular song, which is why only one would be open at a time. When a song patcher is opened, the contents of the coll stored on an instatiated abstraction of that song patcher would be sent to the front panel, thereby setting all the dials and sliders to their previous values for that song. If a dial or slider is changed while a song is open, then the new values are to be silently stored in that coll so that when that particular song patcher is closed (without having to confirm that the patcher has changed, by the way), a subsequent reloading of that song patcher would restore the dials and sliders.
    I've read a ton of tutorial stuff but I think I'm too drunk!
    Any guidance would really be appreciated.
    Thanks, D

    • Dec 25 2011 | 9:36 pm
      Coll doesn't work with pattr in the usual way, but you can save coll in a pattr object as shown here
    • Dec 26 2011 | 12:03 am
      Yeah, I saw that example, but I didn't really understand it --- I guess I'll have to run it with the debugger and try to figure out what's going on and see if I can simply it to a really basic example.
    • Dec 26 2011 | 12:28 am
      I don't think this even does the basics of what I need. For example, I tried editing the coll to store my own data. Then I pressed the "Save Data" button, also saved the patch and closed it. When I reloaded it, the original data (related to lemur stuff) was back in it.
      Even if this worked, I don't understand how to store it as an abstraction and get different data stored depending on the parent patcher in which it's instantiated.
      (I do however understand the trick that's being done to convert the coll data into a symbol and back --- that's cute)
      Maybe I'll have to wait until holidays are over and I can think again!
    • Dec 26 2011 | 12:57 pm
      As I understand it, an abstraction is basically a separate file that has no inherent connection to the patcher in which it's instantiated. But you can create modified abstraction instances by using different argument values. In other words, different behavior depending on the parent patcher can only be achieved with the arguments.
    • Dec 26 2011 | 4:06 pm
      Yeah, I'm a big fan of abstractions anytime I have ANY duplication. Most of my own patches consist mostly of instantiated abstractions which themselves have instantiated abstractions.
      I just wish that there was a more seamless mechanism so that the data belonging to objects such as coll that are part of an abstraction would be saved automatically in the context of the parent (top-level parent if there's multi-level nesting) patcher. I am finding the pattr mechanism too complicated and I probably will end up going to SQLite.
      For now, I just passed in a filename as an argument value and then used that as a parameter for read/write messages to the coll in the abstraction. But that's not a great solution when there are multiple coll objects.