global Maxobj properties?

Jan 10, 2007 at 11:44pm

global Maxobj properties?

This is my first attempt at working with Javascript so please forgive my naivete. I have a very simple function that queries the class, name, and coordinates of named objects in a patch. I want to use it in a nested subpatch below the objects I’d like to query. I’d really like to perform the function globally but I’m stuck on the steps involved. I’ve tried to work up in the subpatch chain using the box property and then down again, but it doesn’t seem to work as needed. Is there something more efficient I’m overlooking? Here is the idea before going up or down in the hierarchy…

Joe Branciforte
____________________________________________________________

autowatch= 1
outlets= 1;
inlets=1 ;

function names(){

var obj = this.patcher.firstobject;

while(obj) {
if (obj.varname !=”") {
outlet(0, obj.maxclass, obj.varname, obj.rect);
obj = obj.nextobject;}
else {obj = obj.nextobject;}
}
}

#29605
Jan 11, 2007 at 2:27pm

I think this is what you’re looking for:

autowatch= 1
outlets= 1;
inlets=1 ;

function names()
{
namesRecursive(top(), 0);
}

function namesRecursive(p, level)
{
if (p)
{
printNames(p);
var obj = p.firstobject;
while(obj)
{
if (obj.maxclass = “patcher”) namesRecursive(obj.subpatcher(), level+1);
obj = obj.nextobject;
}
}
else return
}

function printNames(p)
{
var obj = p.firstobject;
while(obj)
{
if (obj.varname !=”") outlet(0, obj.maxclass, obj.varname, obj.rect);
obj = obj.nextobject;
}
}

function top()
{
var prev = 0;
var owner = this.patcher;
while (owner)
{
prev = owner;
owner = owner.parentpatcher;
}
return prev;
}

Mattijs

#92980

You must be logged in to reply to this topic.