Working with max classes that are NOT objects

    Sep 28 2009 | 7:25 pm
    Hi all,
    I'm working on something at the moment that requires me to get the user to pass in a name that will act as a reference to a particular data structure (as you type names into buffer~/sends/colls etc. etc.). In this case the data structure is the top node of a data hierarchy. The structure in question might be be owned by an object of one of a number of classes.
    Therefore, in order to make this work safely, I want to check that the name I'm being handed is actually bound to one of these structures, and not something else (like a send or whatever), before I start examining the contents of its memory. If the structure is a max class I can use object_class or object_classname or whatever to determine that I have the right kind of object.
    However, what I'm not clear on is where and how should I setup this data structure class. The problems being that this common class needs to be accessible to several other classes and should not be accessible by typing into an object box.
    Any one done this and have any ideas, tips?
    Many Thanks
    Alex Harker

    • Sep 28 2009 | 7:33 pm
      One way to approach this task is to create a 'nobox' object -- that is to say an object that is not instantiated in a box like a normal Max object. Then you could create instances of your new object/struct to carry the data around.
      In Max this is done for various kinds of data stores -- t_linklist, t_hashtab, t_dictionary, etc. They are all nobox classes.
      I also wrote a little bit about this here:
      Hope this helps...
    • Sep 28 2009 | 7:37 pm
      Thanks Timothy! That's awesome. I knew this was possible, and how lots of data stroes in max are done, I've just never had to do it before. Your article seems to cover everything I need.
      Thanks again,
    • Sep 29 2009 | 12:49 pm
      OK. So everything is pretty much working nicely, except for one thing.
      I've made my nobox object as a separate .mxo external. If I load it manually before instantiating any of the objects that depend on it then all goes well. However, if I load one of those objects without loading the external then it crashes (it doesn't load the .mxo from disk, even though it's in the searchpath). Any idea on how I can make this work better?
    • Sep 29 2009 | 4:18 pm
      If you put your mxo in the Cycling '74/extensions folder then Max will load it at launch so it will be available to the other objects when they need it.
      You should probably also make sure that object_new(), or whichever variant you are using, is not returning NULL before you start calling methods on your instance.
    • Sep 30 2009 | 10:31 am
      Ok. Thanks Tim. Figured that there might be a better way, but this is fine if it's the only way.
      Thanks for your help thus far. I'm now using connection_client rather than directly binding to a symbol, as I realised two-way communication would be necessary, and I've run into a problem. If you have a moment could you check out my new post on this, as I'm guessing you might know the answer...
      Thanks again,