A WORKAROUND: path to standalone from within standalone

    Nov 03 2010 | 5:29 am
    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. :)
    ps. I run Max 5.1.4, on MacOS 10.6.4. Does anyone want to confirm or deny this on the other platforms?

    • Nov 03 2010 | 8:02 am
      It does work with Max4.6 under X.6.4 too.
    • Nov 03 2010 | 9:28 am
      >> This isn't as useful as a working built-in function
      To get the "path to standalone from within the standalone", you can send the message "sendapppath" to max :
    • Nov 03 2010 | 9:43 am
      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!
    • Nov 03 2010 | 9:45 am
      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.
    • Nov 03 2010 | 9:46 am
      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.
      _ johan
    • Nov 03 2010 | 9:54 am
      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 :
    • Nov 03 2010 | 4:26 pm
      I found this solution through the forum. You need to use the patcher name.
    • Apr 15 2011 | 10:55 am
      Guillaume Evrard, you just found my solution, in the past like a return to the future concept or else :) thanks a lot!
    • Jan 09 2012 | 11:17 am
      Minor modification to Guillaume Evrard's solution.
      With this little workaround, it now works in every case : Standalone, collective, patcher
    • Jun 05 2012 | 7:42 pm
      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.
    • Dec 13 2012 | 11:07 am
      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?
    • Dec 13 2012 | 12:50 pm
      what is your error?
    • Dec 13 2012 | 3:37 pm
      The path points to MAX installation folder like "C:Program Files...." instead of current application path.
    • Feb 12 2013 | 10:44 am
      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.
      Chris Vik.
    • Apr 18 2014 | 5:54 am
      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/
    • Apr 18 2014 | 6:20 am
      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?
    • Jun 14 2017 | 12:37 pm
      To obtain the absolute path within standalone and editor I adapted Michels solution: