Forums > Javascript

get patcher name (again)

July 17, 2007 | 12:28 pm

Hi.
1st of all, sorry if this sounds very easy and stupid to you but these are my very first steps into JS.

I’m trying to get a bpatcher scripting name from inside of it.
I’ve searched on the javascript list and tried different scripts but can’t get it working.
Now I have a really simple js and I place it inside a named bpatcher and I only get when I ask for his scriptname.
If someone could have a look at the following example…
(I also have the js inside a patcher to compare)

____________________________________
getname.js

function bang()
{
post(this.patcher.varname);
}

____________________________________
testgetname.pat

#P button 36 36 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 36 68 54 9109513 js getname;
#P connect 1 0 0 0;
#P window clipboard copycount 2;

____________________________________
main patcher

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 39 284 188 448;
#P button 36 58 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 36 87 54 9109513 js getname;
#P connect 1 0 0 0;
#P pop;
#P newobj 212 252 36 9109513 p none;
#P objectname wow;
#P bpatcher 105 93 100 100 0 0 testgetname.pat 1;
#P objectname blah;
#P window linecount 3;
#P comment 257 252 100 9109513 this patcher is also named and it also doesn’t work;
#P window clipboard copycount 3;

Thanx.



jln
July 17, 2007 | 1:02 pm


July 17, 2007 | 1:05 pm

That should be

function bang()
{
post(this.patcher.box.varname);
}

Check it out in javascriptinmax.pdf, the varname property belongs to Maxobj, not to Patcher

hth,
Mattijs


July 17, 2007 | 1:20 pm

ach sooo !
I should sleep a little bit more before trying to understand this javascriptinmax.pdf :)
Many thanx to both of you !
Cheers.


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