Getting the name of a subpatch from inside it?

lists@lowfrequency.or's icon

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 Patch
Copy patch and select New From Clipboard in Max.

Stefan Tiedje's icon

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:

Max Patch
Copy patch and select New From Clipboard in Max.

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

Emmanuel Jourdan's icon

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

lists@lowfrequency.or's icon

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
>
>

Stefan Tiedje's icon

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

Mattijs's icon

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

Let me know if it works.

Cheers,
Mattijs

lists@lowfrequency.or's icon

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

Mattijs's icon

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

I updated it, same link.

Mattijs