# $control_par_picture_state



## Robym (Jul 11, 2014)

hello,

i'm using $CONTROL_PAR_PICTURE_STATE for different labels in a GUI.
they all work in callbacks (ex: click on a menu or a switch and the labels change to the desired picture state)

But i have a problem in storing each picture state
i am using make_persistent on all of them and when i recall the instrument or initialise it, the picture state goes to "0" on all the labels
i also tried to make presets using arrays as normal but it does not retrieve the correct picture state value.

what's the best way of doing it?

thank you in advance for your help

Roby


----------



## mk282 (Jul 11, 2014)

Use read_persistent_var after make_persistent and before you change the picture state in the init callback.


----------



## Robym (Jul 12, 2014)

Thank you so much for your reply

i did as follows:

on init...
make_persistent($x_lbl)
read_persistent_var($x_lbl)
set_control_par(get_ui_id($x_lbl), $CONTROL_PAR_PICTURE_STATE, 0)
… etc…

it works on initialisation ...

but the problem is that i have a few on ui_controls (menus and switches) that will change the picture state as needed and i can't find a way to store (in array presets or on the instrument itself) that picture state. When i initialise the instrument it goes back to the picture state of on init and not on the saved picture state (sorry if i'm not too clear).

is there a way at all or are we stuck we the initial picture state?

thank you

Roby


----------



## Robym (Jul 12, 2014)

I actually found a work around for the problem

in the array i was trying to store the picture state…did not work, but

instead i am now storing the value of those menus and switches that trigger the picture state changes and with a series of if/else statements and select() i call the needed picture states like a common on ui_control callback

roby


----------



## mk282 (Jul 12, 2014)

In that code above you're always setting the picture state to 0, that's why it always goes back to it. You need to use the value of the control (ui_menu, if I assume correctly) there.

So, it would look something like this:


```
on init
    declare ui_label $Label (1,1)
    declare ui_menu $Menu
    <add menu items here>
    <assign picture to the label here>

    make_persistent($Menu)
    read_persistent_var($Menu)

    set_control_par(get_ui_id($Label),$CONTROL_PAR_PICTURE_STATE,$Menu)

    message("")
end on
```


Of course, you need to make sure that $Menu has entries that go from 0 to x, without any jumps in ordering of numbers. In case you just want to take the position index of the item in the menu rather than its numeric value, you use get_control_par(get_ui_id($Menu),$CONTROL_PAR_VALUE) instead of just $Menu in that line above.

No if/else or select/case statements needed!


----------



## Robym (Jul 12, 2014)

Thank you so much for your help

i will try it as soon as possible

))


----------

