Share data between each launch of app without saving it to file


#1

Hello, sorry if naive question, but I am not sure how to google it.

I wonder if I can share some variable between each launch of app, without saving it to file.
I know how to save to file, and read it. But I need to do some trivial thing:
I want to show some tip for user when he launch the app. But I want that tip to appear only for example first 2 times he launch the app.

Do I need to save it to the file? Or is there any smarter way?
Best Regards


#2

There is similar question I think. If my app is plugin, and I launch my plugin in more then one instance in Logic or other host, how to set them to have separate variable, different for each instance? For example for beginWaitingForSocket (int portNumber, const String &bindAddress=String()) to set portNumber different for each instance.


#3

Regarding your first post: The class PropertiesFile is your friend :slight_smile:
Second one: use the setStateInformation() and getStateInformation() methods of your AudioProcessor. For the latter I think there is a JUCE tutorial with the AudioProcessorValueTreeState.

In one of my plug-ins I use both, so maybe that could help: https://git.iem.at/audioplugins/IEMPluginSuite/blob/master/SimpleDecoder/Source/PluginProcessor.cpp

I store the presetFolder in the PropertiesFile as I want every instance have the same presetFolder, so the user doesn’t have to search for it every time.
On shutdown, I save the OSCPort of each plug-in with getStateInformation().

However, I just saw that it would be better to make a copy of the state (AudioProcessorValueTreeState) first before adding the properties. See the JUCE tutorial here: https://docs.juce.com/master/tutorial_audio_processor_value_tree_state.html
auto state = parameters.copyState(); <- that copies the stat first.