Forums > Javascript

posit replacement

August 15, 2009 | 12:18 am

Hello,

I’m trying to find a way to replace the posit object, which doesn’t work under max 5 on the pc. Is there an easy way to do this in javascript (about which I know exactly nothing)?


August 15, 2009 | 10:07 am

The javascript below will accomplish the same as [posit] for the "class ", "query ", "objects" and "names" messages. If you need any of the other functionality just ask and I will try to include it. Some things like finding [coll] and [buffer~] names just aren’t possible in javascript (to my knowledge). I hope it helps.

lh


var findclass;
var findvar;

function class(a) {
findclass = a;
this.patcher.apply(iterclass);
}

function iterclass(obj) {
if (obj.maxclass == findclass) {
info(obj);
}
}

function query(a) {
findvar = a;
this.patcher.apply(itervar);
}

function itervar(obj) {
if (obj.varname == findvar) {
info(obj);
}
}

function objects() {
this.patcher.apply(iterall);
}

function iterall(obj) {
info(obj);
}

function names() {
this.patcher.apply(iterallnames);
}

function iterallnames(obj) {
if (obj.varname) {
info(obj);
}
}

function info(a) {
outlet(0,a.maxclass,a.varname || "",a.rect,this.patcher.name);
}


Viewing 2 posts - 1 through 2 (of 2 total)