Retrieving patch title or filename without javascript

Thijs Koerselman's icon

Is there a way to get to the title or filename of a patcher from within?

The only way I know is to use javascript "this.patcher.filepath" and then strip everything but the filename. I don't want to use javascript (it adds an extra file which I really don't want in this case) so I'm looking an alternative. I hoped sending "gettitle" to thispatcher would do the trick but that doesn't work.

Thijs

Jesse's icon

I would expect the "path" message to thispatcher to do this, as the help file describes its function as:

"output the full pathname of the patcher out the right outlet"

This does not appear to be accurate -- instead, thispatcher reports the path of the patcher's enclosing folder.

Thijs Koerselman's icon

Yes, exactly. Too bad :(

roger.carruthers's icon

No joy with this, I take it, so would anyone be kind enough to post the js method for a non js speaker?
cheers
Roger

Luke Hall's icon

Here you go Roger, enjoy!

outlets = 2;

function bang() {
    outlet(0,this.patcher.filepath);
    outlet(1,this.patcher.name);
}
bart at max (previously BITter)'s icon

I also don't like (most of the times) too much files.
A real simple patch that does what you want but not bulletproof. :)
When you keep the names of your max patches in a clear order then you can get
the latest saved one out, when you need this.

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

892.get_max_patch_name.maxpat
Max Patch
roger.carruthers's icon

Excellent, thanks!
cheers
Roger

roger.carruthers's icon

Is it possible to get the name of the patcher the level above the one the js is in? I tried parent.patcher.name, but it was having none of it...
Cheers
Roger

pdelges's icon

Roger,

I think it should be
this.patcher.parentpatcher.name

p

roger.carruthers's icon

Of course! Thanks- I really should learn js one day...
cheers
Roger

Ernest's icon

Twelve years later, it appears one still cannot get the patcher name except by adding a js file to the patch file.

It's not so bad, though, because all the patches in the same directory can easily access the same .js file. And there are other generally applicable methods that are only possible in JavaScript. For example, JavaScript is needed for a tab object, or equivalent, to change the window zoom and properly resize the patch window. So there is a reason to gather such things in a library for all one's patches.