Explicitly declare variables local to a flow or block.

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
User avatar
jassing
Posts: 94
Joined: 16 Jul 2017 01:42
Location: SF Bay Area

Explicitly declare variables local to a flow or block.

Post by jassing » 25 Nov 2019 05:39

Would be nice to declare variables as local to a flow, such that calling another flow won't wind up updating the parent's variable

Also, local to a block

{
local a;
a=5;
}

Just similar to standard C...

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Explicitly declare variables local to a flow or block.

Post by Desmanto » 25 Nov 2019 17:54

Martin ever thought about limiting and selecting which variable to be passed on the child's flow or returned back to parent's flow. Maybe that is better solution. But I don't know how is the progress.

For local block variable, seems unnecessary. I just reuse all the i, j, k from all the loop I used. The value get replace at every new block, so basically the same as having them the same as local block variable. But if you really need to clean up the variable (maybe your script depends on the null value of the variables), you can use removeVariable("a") or any variable name in quotes, before proceeding to the next block.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Locked