Set abstraction name with argument

    May 25 2006 | 3:38 pm
    (OS X.3.9, MMJ 4.5.5)
    I want to be able to set the object name of instances of my abstractions with an argument, a la buffer~, but can't seem to find a way of doing so. In JS returns nothing (I guess because its an abstraction, not a subpatch), and there doesn't seem to be a scripting solution.
    If someone knows a way, or can direct me to a part of the fine manuals that I've missed, I'd be most grateful.

    • May 25 2006 | 4:40 pm
      In fact, not like buffer~ at all, because I was looking for a way to set the objectname that you see in the inspector.
    • May 25 2006 | 6:51 pm
      Are you trying to use a script within an abstraction to name its containing box after it is created? I was trying to do this and couldn't figure it out using, so I found a work around that you may find useful.
      I have one abstraction that generates various others in the parent patch via javascript. When the new abstractions are created I use [maxobj].varname to set the object's name. In other words, I have the script that created it give it a name. Like a good parent.
      Once the abstraction has a name you can rename it from a script inside. Use parent = this.patcher.parentpatcher, then parent.getnamed to get a maxobj of itself and remname it using varname. If there's a way to do it with someone please let us know.
    • May 25 2006 | 7:46 pm
      haha just kidding! I'm new.
      I was calling the from the loadbang function in the script and this doesn't work. You have to schedule the task at a later time (0 ms seems to work though). The same is true for parentpatcher, and probably other functions that return patcher and maxobj objects.
      So... when your abstractions are created you can use, then varname to set the name of your new abstraction. You just can't do it in the loadbang function, or from a [Task].execute() in the loadbang function. [Task].schedule(0) works in the very simple example I just cooked up.
      I seem to remember that this came up before, maybe under a different guise.