# Homeyscript variable gets filled with text instead of value

**URL:** <https://community.homey.app/t/homeyscript-variable-gets-filled-with-text-instead-of-value/75156>\
**Category:** Developers\
**Created:** [January 16, 2023, 12:41pm UTC](https://community.homey.app/t/homeyscript-variable-gets-filled-with-text-instead-of-value/75156 "2023-01-16T12:41:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 16, 2023, 12:41pm UTC](https://community.homey.app/t/homeyscript-variable-gets-filled-with-text-instead-of-value/75156/1 "2023-01-16T12:41:17Z")

</div>

```auto
var waterContractPeriodIndex = global.get('waterContractPeriodIndex');
console.log('waterContractPeriodIndex is: '+waterContractPeriodIndex)
var powerContractPeriodIndex = global.get('powerContractPeriodIndex')
console.log('powerContractPeriodIndex is: '+powerContractPeriodIndex)

test = (sort[count] +'ContractPeriodIndex'+'['+(currentMonth -1) +']');
console.log('waterContractPeriodIndex from test is: '+test);
test2 = waterContractPeriodIndex[0];
console.log('waterContractPeriodIndex from test2 is: '+test2)

```

This is the result:  
waterContractPeriodIndex is: 2023,2023,2024,2024,2024,2024,2024,2024,2024,2024,2024,2024

powerContractPeriodIndex is: 2023,2023,2023,2023,2023,2023,2023,2024,2024,2024,2024,2024

waterContractPeriodIndex from test is: waterContractPeriodIndex[0]

waterContractPeriodIndex from test2 is: 2023

In the test i get the name of the variable but not the value, when i enter the name of the variable in test2 it works. How can i make it work in test

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 16, 2023, 12:57pm UTC](https://community.homey.app/t/homeyscript-variable-gets-filled-with-text-instead-of-value/75156/2 "2023-01-16T12:57:19Z")

</div>

> [@Marcel\_Ubels](#):
>
> `console.log('waterContractPeriodIndex from test is: '+test);`

```auto
console.log('waterContractPeriodIndex from test is: '+eval(test));

```

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 16, 2023, 1:05pm UTC](https://community.homey.app/t/homeyscript-variable-gets-filled-with-text-instead-of-value/75156/3 "2023-01-16T13:05:46Z")

</div>

thx worked at once
