Save the patcher function inside a standalone
I built a standalone app and would like to include a function that the patcher saves to disc at closebang without having a Mac dialog appear.
The idea is to save a few data in the app each time it is closed without asking the user to save it.
Is there any command available to do so? I checked the complete browser but cannot find any. Is there are workaround to get there?
Thanks!
You'll need to save stuff to the standalone's preferences folder.
Cheers
-A
Hi Andrew,
thanks for your quick response, but please forgive my stupidity:
- my app does not have or create a preference folder, or at least I cannot find it. Where would it be? In user/Library/Preferences?
- and how do I save to the preferences? Sorry I've never done that...
- is there any tutorial or so?
Thanks again
this
https://cycling74.com/tutorials/get-your-max-standalone-on-apple%E2%80%99s-mac-app-store
has information re mac but I think you can apply it to windows too
You can set a custom name for your app's prefs using the standalone object, in its inspector.
Then you do something like
to get the path to it, which you can use to save things. In general, users do not have permission to modify apps folders.
Cheers
-A
Thanks Andrew and thanks to Floating Point. That solved my problem, many thanks
Sorry Andrew and Floating Point, but the problem is not solved yet. Yes I can create a folder in "~Library/Application Support", write a .txt-file into it, but I can't read it out, because the separation of the two words "Application" and "Support" makes any "read" command to the "Text"-object assuming additional arguments. When I make a symbol out of the path, it cannot find it. How do I access "Application Support" from within a patch?
Thanks and sorry for bothering so much.
you need to enclose the file path in double quotes, for example:
(read "my mac/Library/Application Support/my text.txt")
you can use the tosymbol object to help with this
Hi Floating Point,
many thanks, in the meantime I found it. I just made to many trials, so that I got confused, I had the solution already, but did not see it, due to over concentration. Sorry for bothering
Many thanks again and have a good day... Hans Peter
Is this method effective for macOS: 15.1.1 (24B91), MAX 9? I tried it and it didn't seem to work.
for most users library folder is invisible.
why not write into documents folder instead ?
you can use unix shortcut to avoid need to detect user name.
write ~/Documents/myfile.json
Thank you for your reply. Like in the attachment?
if you use read or write using
~/Documents/myfile.json
it should read and write the file.
dealing with pattr itself is a different topic.
It is up to you to arrange storing of presets and file so that it does
what you want.
I would not trust closebang in standalone.
If you don't use closebang in standalone then what do you usually do?
Depends on the goal.
Only 100% safe way is to disable usual Quit using
keyboard shortcuts or menu, then add a button
(with a long press to execute)
which first performs what you want,
and after that sends message
;
max quit
Thank you for your sharing and help!
here is example patch
hold quit button > 1000 ms.
if you release button outside of it
it does not execute ....
handling of standalone will be different if you use Windows.
Wow! The parameters were really saved—such impressive technique. You know, resources on this topic are indeed quite scarce, and it has truly stumped many people. Thank you for your generous sharing—I will study your patch carefully! Thanks again!