How can I restore data after quit and reopen (standalone)

Martin.Jirsak's icon

Hi,

How can I restore data I have changed while using standalone (exported from Max), I have changed while using it?

Simple scenario:
- I have a maxpat patch.
- I have a number in it.
- When I build an application, the Number is set to 0.
- I start the built application => Number == 0.
- I change the value in the standalone application => Number == 42
- I quit the standalone application (I would expect to be asked to save the data).
- I reopen the application.

Expected: Number == 42
Current: Number == 0

What object can I use to store the data while quit and restore them when reopen the application?

I have tried [pattrstorage] (also together with [preset]), [dict], [call], none of them was working.

Any idea, link to a tutorial, anything will be much appreciated. Thanks!

Jean-Francois Charles's icon

Whatever storage system you use, you will need to write the data in a file. The file must be saved in an authorized place. Search this forum for information on this topic. You'll find threads like this one: https://cycling74.com/forums/save-the-patcher-function-inside-a-standalone

Martin.Jirsak's icon

Hi,

Thank you for the reply.

Could the file be somehow embed in the standalone application then (or just present in one of its subfolder)?

Jean-Francois Charles's icon

No, that's the point. On a modern PC/Mac, The Operating System decides where you are allowed to write. You will not be allowed to change the content of an application folder. The OS are increasingly concerned with security: the requirements for writing files get only tougher with new OS versions.

Roman Thilenius's icon


wouldnt it be enough to instruct a user to put his copy somewhere else but inside /applications?

Source Audio's icon

At least on mac that would lead to translocation,
and break the standalone.
We need to crack the operating systems
and gain control over our digital lives.

Roman Thilenius's icon


so the remaining stragegy would be to turn off that protection nonsese whereever you can - and then use another computer to browse the web.

but i dont have experience with the last 3 years of macOS, not sure what happens there now when you turn off gatekeeper?

in my opinion, codesigning somehow takes the idea of unix file rights ad absurdum.

Source Audio's icon

one does not need another computer to browse the web.
Security does not depend on gatekeeper and such,
but on user behaviour.
MacOS is getting worse and worse.
All the gain from fast processors etc is just thrown away in favor of
writing logs and protocols about every mouse click, file transfer,
internet login and just about anything one does on the computer.
I usually invest a lot of time with every new system release to
remove all that bloat in order to get a smooth running system.
Apple tries to make it difficult by creating cross dependencies
between processes.
Like if you don't want to allow all your photolibrary to get scanned by face recognition
and sent somewhere out in the dark, by disabling it, then scanning or printing does not work and such shit.
Or if one totaly disables anything to do with icloud, then one can't
enable filesharing on local network.

Nowadays security gets so highly promoted,
but it is exactly the oposite - it never was so easy to control
and route folks just as sheep herd to whatever direction,
dependency on smart phones, social networks ...

I sure am old fashioned and hope to be allowed to continue
living my life without getting forced to take part in all that

Roman Thilenius's icon


yes i know about these quirks and have a similar opinion, but lets say somebody wants to be "safe" (and there are tons of malware for mac since 3-4 years) but make working with apps and documents a bit easier, what would be the best practice?

gatekeeper was easy. until recently you could always make a "multiple clicks installer" by putting symbolic links of system folders in your dmg where the user should move the parts, and then provide a "disable filekeeper" shell script with it.

how could you make your world like that in 10.15?

"Security does not depend on gatekeeper and such, but on user behaviour. "

that is a bit a contradition. when you can only stay safe by becoming a tech expert and avoid 70% of the web, this doesnt result in freedom.

Source Audio's icon

This could become a very long discussion, but I prefer to
keep it short.
I am not giving any advices, and can't offer any good solution to others.
I use dedicated computer for all personal and important stuff,
which can't get infected by whatever, because it is not capable of running any
malware, being java, flash or whatever.
On my other Macs or PCs I don't care if it all goes nuts or not,
systems are ready to get replaced by fresh clones if necessary.
I run most of my mac systems with root account, cause I got tired of entering the password
whenever I want to copy or delete files in prohibited locations.
All files are kept on other partitions or HD's than system.

If it comes so far that I need to use Catalina, because of new hardware,
than it will get taken apart and again freed from all that apple gibberish, and that's it.
Same applies to windows.
That is just my personal opinion and way of using computers.


Source Audio's icon

After hijacking this thread I think it is also time to give some
usefull answer to original question.
The place one is dead sure max or standalone gets allowed to write files
is in location where it stores preferences.
If one sets standalone object with own preferences name, like Myapp
that name will be used to create folder in user library and store all
settings, temp extraction of externals, database etc,etc inside.
On Mac it is /Users/User/Library/Application Support/Myapp
Path can be shortened to ~/Library/Application Support/Myapp
to work for any user name.

So to write a text file PARAMS.txt :
write "~/Library/Application Support/Myapp/PARAMS.txt"
One can embed default settings into standalone,
loadbang :
read "~/Library/Application Support/Myapp/PARAMS.txt"
to check if PARAMS.txt exists and load values from there.
.................
On windows, folder location is in Users/User/AppData/Roaming/Cycling '74/MyApp Files
If one does not want to store into cycling '74 folder, one needs to mod the exe file
and plant own path inside.
---------
Both systems hide that location from user.
Windows is less restrictive than MacOS, so one
can usually write stuff more or less to any location, besides system protected
paths.

Martin.Jirsak's icon

Hi SOURCE AUDIO,

Thank you for this valuable respond.

Source Audio's icon

You are welcome, and sorry again for driffting from original topic.
It's just that it is really annoying that instead of simply having fun
with max, one has to fight that stupid restrictions.

billyanok's icon

Great info from SOURCE AUDIO, I’d just to add that if you’ve codesigned your app for distribution especially now for Catalina 10.15, the location is slightly different.

If one sets standalone object with own preferences name, like “Myapp” and bundle identifier to “com.mycompany.Myapp”, the location will be within the “Containers” folder -

~/Library/Containers/com.mycompany.Myapp/Data/Library/Application Support/Myapp//PARAMS.txt

Source Audio's icon

Thanks for the info.
In that case also Max itself now has to
use the container, right ?
Or from version 8.1x ?