Persistent but user-determined search path for standalone assets
This must be trivial to accomplish but I can't figure it out.
Case: A Max standalone that allows the user to store lots of presets (.json, .maxpresets, .txt etc)
Function: User can set path (e.g. using opendialog fold) to a directory anywhere in the file system where these presets will be saved. This path is recalled when the standalone is launched.
How is this accomplished?
The "Search Paths in Standalones" Guide says:
When your application searches for files outside the collective, you can control where it looks with the Utilize Search Path in Preferences File option. If this option is on (which it is by default), your application will use the search path settings stored in the Max Preferences file instead of using the default search path. You can instruct your application to use its own Preferences file instead of the default Max Preferences by supplying a preferences file name in this field. If the Utilize Search Path in Preferences File is checked and you type in a name other than the default Max Preferences, your application will make its own unique preferences file (in ~ /Library/Preferences , where ~ represents your home directory) the first time it is run. From then on, your application will use that preferences file to recall the settings for options such as Overdrive or All Windows Active (Windows systems only).
But the preferences file does not seem to contain a search path key/value?
It is not so simple. I did implement it in Godel here:
Have a look in filepath help file.
if You want to have searchpath added to Standalone AFTER it is built,
You need to provide such paths.
Open Dialog, send path to filepath search xx (xx = number of path, can be freely assigned)
Max stores preferences when it quits, mind You...
Thank you Ernest and Source Audio.
Source Audio: Filepath seems like the right object. When I create an .app (I'm on Mac OS, 10.12.1, Max 7.3.1 x64) and include a standalone object with @usesearchpath 1 and a custom preferences file name the method you describe works, except the search path created using filepath is not saved on application close.
Maybe I'm still missing something?
Any other tips?
what I do is use a coll to store the file path on quit. the coll writes a text file to a folder within the standalone's directory structure, and reloads the coll file on launch. you'd need to patch this functionality yourself, ie send read and write messages to coll, then access the colls data once it's loaded.
Thank you Floating Point!
I was just figuring this out when you posted.
For future reference here's an example that seems to work:
that looks about right. Well done )