# H.O.O.P. (Hope) - Homey Object Oriented Programming

**URL:** <https://community.homey.app/t/h-o-o-p-hope-homey-object-oriented-programming/43709>\
**Category:** Apps\
**Tags:** app, tools, flow\
**Created:** [March 4, 2021, 6:22pm UTC](https://community.homey.app/t/h-o-o-p-hope-homey-object-oriented-programming/43709 "2021-03-04T18:22:00Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 27, 2021, 8:31pm UTC](https://community.homey.app/t/h-o-o-p-hope-homey-object-oriented-programming/43709/10 "2021-03-27T20:31:57Z")

</div>

> [@H.O.O.P. (Hope) - Examples](https://community.homey.app/t/h-o-o-p-hope-examples/45114/4):
>
> Example Flow Variables - Using variables and a custom function First i created a function called “random” in the App Settings: Enter the next javascript into the function by clicking edit. function (arr) { return arr[Math.floor(Math.random() \* Math.floor(arr.length))]; } Then the next flow: First, put a Javascript Array into a Flow Variable type JSON called Kids. (Variables are created on the fly, no need to define them in settings, just start the flow to use them) Th…

Nice one! It took me a couple hours to reproduce this flow, but it works and I get it. It replaces 5 flows (if using 4 names) of my CatFeedLuckyOne flowset.  
What I found out “the hard way” was this:

> [@H.O.O.P. (Hope) - Examples](https://community.homey.app/t/h-o-o-p-hope-examples/45114/9):
>
> (After you create a flow-variable in flow, they flow needs to be triggered once for the variable to become visible (and to select it)).

**Edit** I just thought, if a variable ‘on the fly’ isn’t created, just create a temp flow with the variable card and test run it. Now you have a selectable ‘existing’ variable 😉

It had saved me some headaches with the variables 😉 😉 But on the other hand, I won’t forget this ‘feature’

Cheers,  
Peter

---

_[View the full topic](https://community.homey.app/t/h-o-o-p-hope-homey-object-oriented-programming/43709)._
