delete a named object

Oct 24, 2006 at 12:42pm

delete a named object

hi and thanks all,

I’m trying to delete object with name with js.
Maybe is a basic question but I’m not able to solve it?

There’s a working code

autowatch = 1;

var p = this.patcher;

function del ()
{
a = p.getnamed (“number_1″);
p.remove(a);
}

But I constrained to a constant, of course.

And there’s a crashing code:

autowatch = 1;

var p = this.patcher;

function del (name)
{
a = p.getnamed (“name”);
p.remove(a);
}

And how can I avoid crashing if I recall a just delated object?

Suggestions?

Many thanks

Matteo

————————–js———————————
prove.js

autowatch = 1;

var p = this.patcher;

function del ()
{
a = p.getnamed (“number_1″);
p.remove(a);
}

———————
prove_crash.js
autowatch = 1;

var p = this.patcher;

function del (name)
{
a = p.getnamed (“name”);
p.remove(a);
}

————————–patcher_example———————————
max v2;
#N vpatcher 174 59 676 406;
#P window setfont “Sans Serif” 9.;
#P comment 314 133 85 196617 name: number_2;
#P newex 128 177 79 196617 js prove_crash;
#P message 210 134 21 196617 del;
#P flonum 275 132 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number_2;
#P newex 128 134 61 196617 prepend del;
#P user umenu 38 98 100 196647 1 64 114 1;
#X add number_1;
#X add number_2;
#P flonum 275 110 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number_1;
#P newex 210 177 48 196617 js prove;
#P comment 313 111 85 196617 name: number_1;
#P connect 3 1 4 0;
#P connect 4 0 7 0;
#P connect 6 0 1 0;
#P pop;

#28324
Oct 24, 2006 at 7:23pm

Forgotten:
maxmsp 4.6.2
jitter 1.6.2
osx 10.4.8
PPc powerbook 1 GH 1G ram

matteo

#86822

You must be logged in to reply to this topic.