I wrote a simple routine that will automatically return the path correctly whether running as a patch or an app (path message to thispatcher for a patch, sendapppath message to max for an app) based on some help I got on the forum:
But then I discovered a strange thing:
If I save it as a patch and use it as an abstraction (I gave it an inlet to the loadbang and an outlet from the switch) it works.
It also works in a bpatcher.
But if I encapsulate the code in a subpatcher it behaves like an app. ???
I wanted to write this because it bugged me to have one structure in a patch and then to have to change to a different structure before building the app. But I don't understand the behavior of the subpatcher. Any insight into this?
I should point out that the patch version only works after the patch has been saved. So if you copy the compressed code and "File/New from Clipboard" it won't work properly until you save the patch (because it doesn't have a path until you save it somewhere). And obviously to see how it works as an app you have to build the app. This is all mac app stuff - I have no way to test this under windows.
I wasn't really concerned with how to get it to work. As I pointed out using the code as an abstraction or in a bpatcher works (and is easier to toss into any patch - I saved the second patch in this thread as "path.maxpat")
I was really just trying to figure out what was going on with the subpatcher. It seems odd to say that it isn't saved to disk when it gets saved with the top level patcher - but "not directly" as you said.
Another case of (me) being confused by what is and isn't communicated between the patch and the subpatch. Is this spelled out comprehensively anywhere in the documentation?
The problem with putting thispatcher in an abstraction/bpatcher is that it will return the path to the abstraction, not to the patcher in which it's embedded, which may not be what you want.
As far as this being spelled out in the doc somewhere, I don't really know. It's worked like this so long, that it just sort of seems like old knowledge to me; I know it's been discussed on the forum a few times.
That's very helpful. My "path" patch that I was using in the bpatcher, and as an abstraction, was in the same directory as my patch so I didn't catch that it was returning its own location and not the patcher that contained it. Thanks.
I think the comprehensive documentation that cycling provides is amazing. It's one of the ways that I was able to sell the college where I teach into buying 20 seats and offering Max as a Fine Arts elective. It's one of the things I stress to my students as I try to get across to them the importance of figuring this stuff out on your own. However,
The problem with "old knowledge" is that "new people" come along.
And perhaps the reason some of these things get discussed over and over is that they're not written down.