# Save different returns for looped function

**URL:** <https://discourse.processing.org/t/save-different-returns-for-looped-function/13686>\
**Category:** Beginners\
**Created:** [August 29, 2019, 1:54pm UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686 "2019-08-29T13:54:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![b\_and\_z](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@b\_and\_z](https://discourse.processing.org/u/b_and_z)\
**Post date:** [August 29, 2019, 1:54pm UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/1 "2019-08-29T13:54:13Z")

</div>

Hi all  
So I have a function that creates multiple sliders. The function is then looped to create multiple sliders. I want the slider values to be stored in an array, for each slider a single array element. How would I have to do that without making a variable for every single slider?

[https://editor.p5js.org/RBvonRB/sketches/zMBKdiAVm](https://editor.p5js.org/RBvonRB/sketches/zMBKdiAVm)

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 30, 2019, 5:06am UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/2 "2019-08-30T05:06:54Z")

</div>

best is to make the sliders as a array, not the slider.value only?

[https://editor.p5js.org/kll/sketches/rRjOfo2nI](https://editor.p5js.org/kll/sketches/rRjOfo2nI)

this shows a possible function,  
as the words are inherent good or bad,  
the color (red … green) i tried is worthless  
it’s just to show coding possibilities ( slider feedback )

---

<div class="post-metadata">

**Author:** ![b\_and\_z](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@b\_and\_z](https://discourse.processing.org/u/b_and_z)\
**Post date:** [August 31, 2019, 9:44am UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/3 "2019-08-31T09:44:24Z")

</div>

Thanks for your suggestion, I should have specified my question. The sliders are only the first step in the process. After setting the sliders, you can proceed to the next page, where a picture is calculated based on your answers. For that picture, I need all the slider values stored and separately accessible.

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [August 31, 2019, 10:10am UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/4 "2019-08-31T10:10:17Z")

</div>

In Kll’s code the values of each slider is properly displayed on the canvas. Your next step could be to figure out how (and when) those values get stored as well. Will you save those values constantly in an array? Will the values be stored once the user pressed the ‘next’ button?

Hope this helps! 🙂

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 31, 2019, 10:31am UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/5 "2019-08-31T10:31:52Z")

</div>

rev: check my example again please.

---

<div class="post-metadata">

**Author:** ![b\_and\_z](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@b\_and\_z](https://discourse.processing.org/u/b_and_z)\
**Post date:** [August 31, 2019, 10:43am UTC](https://discourse.processing.org/t/save-different-returns-for-looped-function/13686/6 "2019-08-31T10:43:37Z")

</div>

That’s what I was looking for, thanks to both of you
