# Start pattern with a slider in a specific position

**URL:** <https://forum.electromage.com/t/start-pattern-with-a-slider-in-a-specific-position/3172>\
**Category:** Patterns and Code\
**Created:** [September 16, 2023, 8:56pm UTC](https://forum.electromage.com/t/start-pattern-with-a-slider-in-a-specific-position/3172 "2023-09-16T20:56:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hololit](https://forum.electromage.com/letter_avatar_proxy/v4/letter/h/5daacb/32.png) [@hololit](https://forum.electromage.com/u/hololit)\
**Post date:** [September 16, 2023, 8:56pm UTC](https://forum.electromage.com/t/start-pattern-with-a-slider-in-a-specific-position/3172/1 "2023-09-16T20:56:49Z")

</div>

Hello !

I’m using a slider in a pattern that returns a log variable between 0 and 10.

```auto
export function sliderManualEnergy(n){
  manualEnergy = exp(logmin + (logmax-logmin)*n);
}

```

Is it possible to have the slider and its associated value start at a very specific position (manualEnergy=1 for example) whenever i start the pattern ?  
At the moment the slider is always at the maximum (n=1) when i start the pattern.

Thank you !

---

<div class="post-metadata">

**Author:** ![jeff](https://forum.electromage.com/user_avatar/forum.electromage.com/jeff/32/3473_2.png) [@jeff](https://forum.electromage.com/u/jeff)\
**Post date:** [September 16, 2023, 10:50pm UTC](https://forum.electromage.com/t/start-pattern-with-a-slider-in-a-specific-position/3172/2 "2023-09-16T22:50:25Z")

</div>

Hey! So, a funny thing is that the initial UI position for a slider is full-right, IE a value of 1.0.

However, if you set a variable in the slider handler, it’s never set until the slider-change handler is called at least once (you move the slider). After that point, the pattern saves a copy of the last known slider value, and it will be re-initialized whenever the pattern is launched, say from the pattern list or by re-editing it. You can observe this with the vars watcher:

![Monosnap Desk 2 2023-09-16 15-41-48](https://forum.electromage.com/uploads/default/original/2X/f/f51d1a79fe0027c14513d2f1ab77fc14fe297bd0.png)

So try setting your sliders once after you create them, and see if that helps.

@wizard - do you think this could be enhanced to call the handler with a value of 1 on initial load if there’s no saved value for a UI Slider control? I notice it often when downloading patterns from the library. One option would be to start including UI Control values in .epes, but a potentially quicker improvement would be to just call the handler once on load with something other than a null value. If the UI shows 1.0, it makes sense to me to call it with a 1.0. I know you might have other things in the backlog for 2-way binding.

---

<div class="post-metadata">

**Author:** ![hololit](https://forum.electromage.com/letter_avatar_proxy/v4/letter/h/5daacb/32.png) [@hololit](https://forum.electromage.com/u/hololit)\
**Post date:** [September 17, 2023, 4:04pm UTC](https://forum.electromage.com/t/start-pattern-with-a-slider-in-a-specific-position/3172/3 "2023-09-17T16:04:45Z")

</div>

Ah yes, i didn’t notice it kept the last value. That’s good enough for me, and actually better to “save” the best preset. Thank you !
