# Passing a variable into a function

**URL:** <https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260>\
**Category:** Questions about Thunkable X\
**Tags:** design\
**Created:** [December 17, 2021, 3:42pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260 "2021-12-17T15:42:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![huntchzk](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@huntchzk](https://community.thunkable.com/u/huntchzk)\
**Post date:** [December 17, 2021, 3:42pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260/1 "2021-12-17T15:42:11Z")

</div>

I am sure somebody has solved this:  
 ![Assigning list of variables to series of fields](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/b/7b495bedc89ae44d69e8e5a215f10bcb7e1ffeed.png)

I have a list of values, and I want to assign each value in turn to a series of labels:

variable MyList = a,b,c,d  
set Label1’s text to (get from MyList #1)  
set Label2’s text to (get from MyList #2)  
set Label3’s text to (get from MyList #3)  
set Label4’s text to (get from MyList #4)

If I was hand coding I would have a loop, something like  
variable MyList = a,b,c,d  
j=1  
Do while j \< 5  
set \<Label & j\>'s text to (get from MyList #j )  
next j

Is this possible in the blocks?

I did try to insert a picture of the problem, not sure it worked  
Christopher Hunt

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [December 17, 2021, 4:19pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260/2 "2021-12-17T16:19:58Z")

</div>

Are you looking for something like this?

> [@\[Invitation to Submit Your App\] Thunkable Best Apps of 2021! sparkles](https://community.thunkable.com/t/invitation-to-submit-your-app-thunkable-best-apps-of-2021/1648179/24):
>
> When I designed and shared the Mastermind game that you taught me for the WDC, I used a similar trick It is sometimes gives more meaning.

---

<div class="post-metadata">

**Author:** ![huntchzk](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@huntchzk](https://community.thunkable.com/u/huntchzk)\
**Post date:** [December 17, 2021, 4:38pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260/3 "2021-12-17T16:38:26Z")

</div>

That does exactly what I want:  
 ![Assigning list of variables to series of fields solution](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/0/20ca1742876fc08cff5a8037de924e0d60f17257.png)

Much cleaner  
Had to search for the “Any component” drawer

Thanks

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [December 17, 2021, 4:41pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260/4 "2021-12-17T16:41:22Z")

</div>

> [@huntchzk](#):
>
> Had to search for the “Any component” drawe

Sometimes, this drawer becomes a _code_ saver.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [March 17, 2022, 4:41pm UTC](https://community.thunkable.com/t/passing-a-variable-into-a-function/1656260/5 "2022-03-17T16:41:34Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
