A WORKAROUND: path to standalone from within standalone

supertwang's icon

Hey y'all,

After struggling with this for a while, I think I've found a workaround. Even better, it seems to work within (top-level) patches, and collectives.

I believe that (loadbang) -> (".") -> (absolutepath) returns the path to the directory in which the .mxf file that was opened lives.

This isn't as useful as a working built-in function, or object, would be but might help others figure out "WHERE THE HECK THEY ARE" on the filesystem. :)

ST

ps. I run Max 5.1.4, on MacOS 10.6.4. Does anyone want to confirm or deny this on the other platforms?

pdelges's icon

It does work with Max4.6 under X.6.4 too.

p

ch's icon

Hi,

>> This isn't as useful as a working built-in function

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

To get the "path to standalone from within the standalone", you can send the message "sendapppath" to max :

Edo Paulus's icon

Zach Poff's Multiscreener software, developed in MaxMSP, uses an elegant solution to find the path.
The patch first checks whether it is running in standard MaxMSP or whether it is in a standalone compiled app.
Depending on that outcome it then reports the path of the location of the patch-file or the path of the location of the standalone app.
Download it here (standalone and source patches):
http://www.zachpoff.com/software/multiscreener/
Then find the part in the source patches that does this. It's isn't that big of an app so pretty easy to find.

Thanks to Zach Poff!

edo.

pdelges's icon

I think the topic's title doesn't match the trick supertwang explains.

What he proposes returns the path to the patch location, or to the collective location. sendapppath will return the location of a standalone (and if used in a collective, of Max itself), which is not the same thing.

p

jvkr's icon

In the same struggle I had taken another approach. The 'path' message to [thispatcher] normally only works in a patch. But inside an abstraction (see below) that is hidden upon building the app, and later added manually, this functions well.

Your solution is simple and straightforward. However it relies on the fact that the search path is still pointing to the default location, a potentially unstable thing, maybe.

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

_
johan

Guillaume Evrard's icon

hi,

if it can help, here is my method. I added a unix format of the path to use paths with some mxj objects.

it works well on windos/mac, in editable patch or standalone. but i think it could be a problem with mxf : the sendapppath message to max will return the path to Max5 application folder, and "path" to thispatcher will give "/".

here it is anyway :

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

Michel's icon

I found this solution through the forum. You need to use the patcher name.

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

Julien Bayle's icon

Guillaume Evrard, you just found my solution, in the past like a return to the future concept or else :)
thanks a lot!

Guillaume Bertrand's icon

Minor modification to Guillaume Evrard's solution.

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

With this little workaround, it now works in every case : Standalone, collective, patcher

kleurbleur's icon

Minor problem with this last one is that it seems that it doesn't tell me on which harddrive it is.
Since I have multiple harddrives in my MacPro it seems that jit.qt.record doesn't know where to write to.

Jassio's icon

Hi,

I tried to use all of mentioned solutions. None of them was working on my Max 5.1 and Windows 7. Can someone confirm that at least one of them still works in this environment?

Julien Bayle's icon

what is your error?

Jassio's icon

The path points to MAX installation folder like "C:Program Files...." instead of current application path.

Chris Vik's icon

The patch below is a combination of Guillaume Evrard and Michel's solutions so that the absolute path SHOULD be discoverable in both .maxpat AND standalone formats.

When you use it as an object, give it an argument with the filename of which you are using the object in (if you intend to use it in both patcher and standalone).

Save the patch as, just say path.system.maxpat... you might call it like:
[path.system filename.maxpat]

Left outlet is the path, right outlet is the OS. Bang inlet to refresh.

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

Chris Vik.

dave leith's icon

Does anyone have a solution for this with Mavericks and Standalones?

The above patcher from EthnoTekh Chris seems to work fine in a Mavericks patcher but not in a Standalone. Outputs seems to be /Applications/Max6.1/

dave leith's icon

The only solution I have found so far with Mavericks is to put the YourStandalone folder with any external files like audio etc. in the Applications folder and just include an absolute path to it. Seems to work no matter where the mxf file is. Is there a better solution?

Roland Sproll's icon

To obtain the absolute path within standalone and editor I adapted Michels solution:

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