States how to save and load

Hi,

could someone help me out with examples on how to do this?

What i need:
I would like to make several save slots, when one of these is choosen some midi messages should not be sent (prevent of overwritting the current widgets). These save slots should work individually for every preset. When none of these save slots is select it should work as read only (as it is working now).

It should be done in a custom module.

My first tries are with two buttons, one for save and one for load.
If it should be readonly or not is set with a boolean variable in the custom module(to be changed by an array of save preset names).

I get some kind of weird loop leading to an type error (caused by more then one time the oscoutfiler function is called -> where does the custom module normally continues after /STATE/OPEN ) ?

Thanks!

EDIT:
Follow up question:
Now i got a basic store and load working:

button 1:
receive('/STATE/SAVE','state1.state');
stateLoad = false;
button 2:
receive('STATE/OPEN','state1.state');
stateLoad = true;

just when stateLoad is false updates are requested from the hardware via midi on several points in the custom midi.

Apart from the fact that i am not sure why some outfilter functions are triggered, it seems to somehow not work with clones.
The following scenario:
Panel - button
- modal 1 (with switch and buttons inside)
- modal 2 (30 knobs and 30 text widgets inside)

The Panel is cloned several times, when calling STATE/SAVE in the file the clones are not listed and with STATE/OPEN every clone is getting the same value.