file paths in standalone applications

Jul 13, 2012 at 4:08pm

file paths in standalone applications

I’m trying to build a standalone application. At present, the patcher lives in a folder in which are all the sound files that it uses.
The folder is in my home folder (mac).

I’ve been trying all manner of things to make the application so it can work on other peoples computers with their differently named home folders, i.e. to make it work independently of being in any specific named location. This is a file path problem I guess, maybe they have absolute paths and need relative ones, but I can’t get it to work. Any advice ?

Thanks,

Jem

#35923
Jul 13, 2012 at 4:22pm

if you are storing anything on the home folder i would suggest using [shell] message into that object “whoami”. That will give you the home folder name. YOu can then create your path using the sprintf object and newly found homefolder path. (shell obj is found at CNMAT collection of MaxMsp externals).

To find the application path create a messagebox with “; Max sendapppath path”, then create a receive object (NOT ‘r’ but ‘receive’) with path as its routing (aka new obj “receive path”).

Hope that helps,
Protocol

#123068
Jul 13, 2012 at 4:32pm

As an alternative for the shell object, you could send the message Desktop to the absolutpath object.

#123069
Jul 13, 2012 at 5:57pm

Thanks, I’ll try these strategies . . .

Jem

#123070
Jul 13, 2012 at 5:59pm

Thinking about this – is there not a way to simply set a file path relative to an enclosing folder. So the application would be within the folder alongside the files it needs ?

Jem

#123071
Jul 13, 2012 at 8:36pm

@Jem: If you want to set the file path relative to an enclosed folder I would suggest sending the Max Message ‘SendApppath’, if its going to be a standalone, that would find that path of the Standalone directly which would be the folder its in (if its in a folder) – aka the path with all the files it needs then you’re golden for finding/reading/writing all the files it needs if its there. I would do that over the [shell] or [absolutepath] shinannagins.

@jvkr: Wicked suggestion, thanks! I can now get rid of using the [shell] object as that was what i used it for. Its nice to finally be free of 3rd party externals! Thank you!

#123072
Jul 14, 2012 at 12:27am

thanks a lot, this sounds a lot more straightforward.

Jem

#123073

You must be logged in to reply to this topic.