Specify js file via relative path

Alex Parkinson's icon

My device is outside of my max path, subpatchers are in the "patchers" subdirectory, and js files are in a "code" subdirectory of the main project. I'd like to be able to reference js files from within my subpatchers, but none of the following seem to work: [js filename.js], [js code/filename.js], [js ../code/filename.js]. How can I reference these js files using relative file paths from within my subpatchers?

Nodanoma's icon

Yes, very frustrating :)

it sounds like your are working in a project-structure but not operating the main .maxproj itself which sets up all these dependencies for all subpatchers as it opens the project. So, if you open the patchers individually, the project folders are blocked from the search path (possibly to avoid duplicates) and Max cannot find the files. Whenever I open patchers individually without the project, I always use filepath to temporarily add the project folder to my search path and revert when done. Later, when operating the project, all dependencies are met anyway.

Max Patch
Copy patch and select New From Clipboard in Max.
I saved this as snippet to be able to edit patchers of projects with all their dependencies, but without opening the project

Hope, this helps.

Joshua Kit Clayton's icon

As of Max 8.6 you can use the special "Patcher:/" virtual volume, e.g. "Patcher:/../code/filename.js"

Jan M's icon

Didn’t know that. It’s a great feature!!!

Nodanoma's icon

Patcher:/…

Interesting…! where is this documented?

TFL's icon

+1 for the doc! [absolutepath] and [conformpath] reference pages do mention some prefixes (C74, usermax, desktop, Package, etc.) but not Patcher:/

Would be worth a small section maybe around here in the doc IMO.

Joshua Kit Clayton's icon

I've updated the absolutepath and conform path reference files for a future version, and I agree TFL that that is a good place to put it in the User Guide.