# Little help with a slider, please



## RiffWraith (Mar 9, 2013)

Hi 

Having a small problem getting a slider to be in default position.

In the insert fx rack, open an eq.

Apply the following:


```
on init 
set_ui_height_px(340)
make_perfview 

declare ui_slider $lowgain(1000,1000000)
make_persistent($lowgain)
set_knob_defval($lowgain,500000)
set_control_par(get_ui_id($lowgain), $CONTROL_PAR_MOUSE_BEHAVIOUR, -2500)
set_control_par_str(get_ui_id($lowgain), $CONTROL_PAR_PICTURE,"pv_band_master_fx_eq_fader")
end on

on ui_control($lowgain)
set_engine_par($ENGINE_PAR_GAIN1,$lowgain,-1,0,1)
end on
```

Everything works fine, save for the fact that the slider is always all the way down when the instrument loads - the eqiuv of -18.0 on the eq. I would like to get the slider to be centered, but no matter what I set *set_knob_defval *to, it's always all the way down. What am I missing?

Also, do I need the* read_persistent_var *command, or is that not necessary here?

Thanks in advance.


----------



## ScoringFilm (Mar 9, 2013)

RiffWraith,

The script is fine as it is and should remember the setting; are you sure that nothing else is affecting this (a #CC setting perhaps)?

The set default value is for control/click; however you could add the following line:

$lowgain := 500000

read_persistent_var is only needed when the value needs to be read on initialisation (i.e. not in this case)

Justin


----------



## mk282 (Mar 9, 2013)

set_knob_defval() will only set the default value for the slider WHEN YOU CTRL+CLICK IT to default it.

To explicitly set a control to a value, just do:

$lowgain := 500000

or to whatever you want.


----------



## RiffWraith (Mar 9, 2013)

*$lowgain := 500000 *is it - thanks guys!


----------



## Alan Wave (Aug 4, 2015)

Hello, i had the same question and tried the solution above, but after i hit ctrl + click on the slider, the slider won't return to the value i set it to. It is going to the lowest value instead. I use Kontakt 5 by the way


----------



## EvilDragon (Aug 4, 2015)

Then you either didn't define the default value for the control, or the default value you've defined is outside of the range of the UI control.


----------



## Kore G (Aug 4, 2015)

Alan Wave said:


> Hello, i had the same question and tried the solution above, but after i hit ctrl + click on the slider, the slider won't return to the value i set it to. It is going to the lowest value instead. I use Kontakt 5 by the way



Try this 

set_control_par(get_ui_id($name),$CONTROL_PAR_DEFAULT_VALUE,500000)

value and the name up to you.


----------

