Getting the name of a subpatch from inside it?

Jan 3, 2008 at 8:58am

Getting the name of a subpatch from inside it?

Hi list

I’m trying to create a named subpatch with a pattrstorage outside it,
referencing pattrs inside it. I want to retrieve presets for only
certain pattr objects in the subpatch, and I want to be able to make
many copies of the subpatch and have each one automagically query the
main pattrstorage object for preset data about its included pattrs
without having to name each one explicitly.

My question is, is there a way to get the name of a subpatch from
within it, besides using javascript?

Here is an example patch of what i’m working on:

max v2;
#N vpatcher 20 74 620 474;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 282 219 65 196617 r $0-preset;
#P newex 392 284 59 196617 print pstor;
#P message 270 49 78 196617 clientwindow;
#P message 272 72 78 196617 storagewindow;
#P message 271 96 81 196617 getslotnamelist;
#P message 270 126 115 196617 storage_colwidth 110;
#P newex 492 125 50 196617 t b l;
#P number 424 86 35 9 0 0 68 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 424 109 50 196617 insert $1;
#P message 362 218 30 196617 grab;
#P message 492 153 50 196617 renumber;
#P number 492 83 35 9 0 0 64 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 425 134 35 9 0 0 64 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 492 105 52 196617 delete $1;
#P message 327 154 58 196617 writeagain;
#P newex 392 252 88 196617 pattrstorage test;
#X client_rect 319 333 959 573;
#X storage_rect 0 0 640 240;
#P objectname test;
#P message 327 175 35 196617 write;
#P message 425 155 50 196617 store $1;
#N vpatcher 61 511 661 911;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 20 192 138 196617 oot whoot boot;
#P newex 20 162 62 196617 prepend set;
#P message 32 98 76 196617 something else;
#P message 14 74 76 196617 oot whoot boot;
#P newex 20 133 84 196617 pattr some_list;
#X prestore 3 0 oot whoot boot;
#P objectname some_list;
#P message 281 97 151 196617 getvalue subpatch::some_list 1;
#P message 314 124 180 196617 getstoredvalue subpatch::some_list 2;
#P message 381 194 180 196617 getstoredvalue subpatch::some_list 1;
#P newex 372 254 65 196617 s $0-preset;
#P message 364 157 139 196617 recall subpatch::some_list 1;
#P window linecount 2;
#P comment 14 41 100 196617 click here and set some data.;
#P window linecount 10;
#P comment 205 162 100 196617 question: how can i get the name of
this subpatch from within it , so I can send the appropriate message
to the pattrstorage outside it to recall selected preset values for
named objects?;
#P connect 9 0 7 0;
#P connect 8 0 7 0;
#P connect 7 0 10 0;
#P connect 10 0 11 0;
#P connect 6 0 3 0;
#P connect 5 0 3 0;
#P connect 4 0 3 0;
#P connect 2 0 3 0;
#P pop 1;
#P newobj 56 253 57 196617 p subpatch;
#P objectname subpatch;
#P comment 124 253 100 196617 < -- look inside here;
#P connect 19 0 4 0;
#P fasten 17 0 4 0 275 67 397 67;
#P fasten 16 0 4 0 277 92 397 92;
#P fasten 5 0 4 0 332 172 397 172;
#P fasten 2 0 4 0 430 174 397 174;
#P fasten 3 0 4 0 332 197 397 197;
#P connect 9 0 4 0;
#P connect 10 0 4 0;
#P fasten 11 0 4 0 429 129 397 129;
#P connect 13 1 4 0;
#P fasten 14 0 4 0 275 145 397 145;
#P fasten 15 0 4 0 276 116 397 116;
#P connect 4 0 18 0;
#P connect 12 0 11 0;
#P connect 7 0 2 0;
#P connect 8 0 6 0;
#P connect 6 0 13 0;
#P connect 13 0 9 0;
#P pop;

#35194
Jan 4, 2008 at 6:37am

evan.raskob [lists] schrieb:
> My question is, is there a way to get the name of a subpatch from within
> it, besides using javascript?

only javascript, including the rectangle of the patcher, save as
myname.js and bang it…

outlets = 2;
setoutletassist(0,”my scripting name (list)”);
setoutletassist(1,”my rect (list)”);

function bang()
{
if(this.patcher.box){
outlet(0, this.patcher.box.varname);
outlet(1, this.patcher.box.rect);
}
}

here is the help file:

#P window setfont “Sans Serif” 9.;
#P number 204 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 167 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 130 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 93 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 93 107 121 196617 unpack 0 0 0 0;
#P outlet 44 111 15 0;
#P button 44 53 15 0;
#P newex 44 81 59 196617 js myname;
#P window linecount 3;
#P comment 136 59 184 196617 in addition the right outlet will give the
coordinates of the patcher in the parent patch….;
#P connect 4 3 8 0;
#P connect 4 2 7 0;
#P connect 4 1 6 0;
#P connect 4 0 5 0;
#P connect 1 1 4 0;
#P connect 1 0 3 0;
#P connect 2 0 1 0;
#P window clipboard copycount 9;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#119717
Jan 4, 2008 at 10:02am

On 4 janv. 08, at 07:37, Stefan Tiedje wrote:

> outlets = 2;
> setoutletassist(0,”my scripting name (list)”);
> setoutletassist(1,”my rect (list)”);
>
> function bang()
> {
> if(this.patcher.box){
> outlet(0, this.patcher.box.varname);
> outlet(1, this.patcher.box.rect);
> }
> }

If I may, I would suggest swapping the 2 outlets calls, so it outputs
from the right to the left, like what you generally expect in a
standard Max object.

function bang()
{
if(this.patcher.box){
outlet(1, this.patcher.box.rect); // output first to the right
outlet
outlet(0, this.patcher.box.varname); // then to the left
}
}

Cheers,
ej

#119718
Jan 4, 2008 at 10:48am

yeah, I was hoping to avoid js, though, because I might want to
create large numbers of subpatches and a compile C external would be
better suited, me thinks.

Thanks for the handy script, anyway! I’ll use it for now.

Funny, but now I finally understand why you want a “pattrbackward”,
Stefan. I never understood what it would be useful for until now.

Here’s my feature reuest: it would be nice if thispatcher could
output the scripting name of a patcher it was inside. I’m actually
surprised that it can’t – it can do everything else. (Unless I am
missing something)

Cheers
Evan

On Jan 4, 2008, at 10:02 AM, Emmanuel Jourdan wrote:

> On 4 janv. 08, at 07:37, Stefan Tiedje wrote:
>
>> outlets = 2;
>> setoutletassist(0,”my scripting name (list)”);
>> setoutletassist(1,”my rect (list)”);
>>
>> function bang()
>> {
>> if(this.patcher.box){
>> outlet(0, this.patcher.box.varname);
>> outlet(1, this.patcher.box.rect);
>> }
>> }
>
>
> If I may, I would suggest swapping the 2 outlets calls, so it
> outputs from the right to the left, like what you generally expect
> in a standard Max object.
>
> function bang()
> {
> if(this.patcher.box){
> outlet(1, this.patcher.box.rect); // output first to the
> right outlet
> outlet(0, this.patcher.box.varname); // then to the left
> }
> }
>
> Cheers,
> ej
>
>

#119719
Jan 5, 2008 at 11:25am

Emmanuel Jourdan schrieb:
> If I may, I would suggest swapping the 2 outlets calls, so it outputs
> from the right to the left, like what you generally expect in a standard
> Max object.

You may, thanks a lot, I am still a js newbie… ;-)

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#119720
Jan 5, 2008 at 1:14pm

Hi Evan, I made you an external that outputs the name of its containing subpatcher:

http://arttech.nl/scriptname.zip

Let me know if it works.

Cheers,
Mattijs

#119721
Jan 5, 2008 at 2:56pm

Brilliant! Thanks for that.

Just one oddity, though – it outputs the name (left outlet) before
the right outlet (index). Keeping with max standards, this should be
reversed, no?

Best
Evan

On Jan 5, 2008, at 1:14 PM, Mattijs Kneppers wrote:

>
> Hi Evan, I made you an external that outputs the name of its
> containing subpatcher:
>
> http://arttech.nl/scriptname.zip
>
> Let me know if it works.
>
> Cheers,
> Mattijs
> –
> SmadSteck – http://www.smadsteck.nl
> Hard- and software for interactive audiovisual sampling

#119722
Jan 5, 2008 at 4:35pm

Haha, same mistake as Stefan! Don’t we ever learn?

I updated it, same link.

Mattijs

#119723

You must be logged in to reply to this topic.