Global variable and widget

Post your questions and help other users.

Moderator: Martin

Post Reply
Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Global variable and widget

Post by Lucy » 14 Nov 2019 08:53

Lol ive tried and tried, even imported flows but can never figure out how to add global variables properly. I have no idea what im doing even after reading tutorials

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: Global variable and widget

Post by Wibbly » 14 Nov 2019 13:43

If you use a variable name in one flow where the variable name starts with "global_", then that variable (and it's contents) becomes available for use in any other flow

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Global variable and widget

Post by Lucy » 14 Nov 2019 13:47

Sorry, yeah i get the idea. I just cant seem to have any of them function with the associated values in widgets nor can i figure out a great number of correct values to do a lot of actions. But thank you

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

Re: Global variable and widget

Post by Desmanto » 22 Nov 2019 17:23

Glovar is just the same local variable as the ones you used, except it stays after the flow execution. Widget can also store value in the text field, so essentially makes them behave just like glovar, but with limited capability (it can't store map/list or event pure location type variable).

The widget text can be set to certain glovar, by using {global_text} in the text field. But I personally avoid this method. SInce we have to store our value first in the glovar, and increasing the glovar usage. The more glovar you have, the slower your overall flow execution, so avoid storing everything there.

I personally prefer to use setWidgetElementProperty(), to change the widget text directly from the script. This doesn't require glovar, and the value persist after execution (behaves just like glovar). Makes it perfect to store some text too. You can find the setWdiget function from the script/expression > function > find setWidget and you can choose to change any widget property you want.
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.

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Global variable and widget

Post by Lucy » 22 Nov 2019 21:17

Thanks hunny... i sorted out my mistakes and got a grip on it now

Post Reply