I’m trying to get a list of the nodes in a group using .queryTree. The man page gives a good example of it’s use, however I cannot get it to behave the way it’s described.
// now query my tree and post a graph of it (duplicates dumpTree)
// msg format is ['/g_querytree.reply', node1-ID, numChildren, defName, child1-ID, numChildren, ...]
(
g.queryTree({|msg|
var i = 1, tabs = 0, dumpFunc;
("NODE TREE Group" + msg[1]).postln;
if(msg[2] > 0, {
dumpFunc = {|numChildren|
tabs = tabs + 1;
numChildren.do({
i = i + 3;
tabs.do({ " ".post });
msg[i].post;
(" " ++ msg[i + 2]).postln;
if(msg[i + 1] > 0, { dumpFunc.value(msg[i + 1]) });
});
tabs = tabs - 1;
};
dumpFunc.value(msg[2]);
});
});
)
This is from the man page. It shows .queryTree accepting a function. I cannot get this to work.
What am I doing wrong?