• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Variables %SCREEN and %WIFI always SET?

Plecto123

Newbie
How come the variables %SCREEN and %WIFI are always SET regardless of whether the screen is on/off or the wifi on/off? I've got a Huawei Honor 5x and Android 5.1.1
 
Seems like the variables store "on" and "off", having %SCREEN eq off, and %SCREEN eq on, instead of SET/!SET worked :)
 
eq works fine for me, but whats the difference between equals and matches? Also, when is a variable !SET? When its completely empty?
 
Matches - look up pattern matching ... in this case they both work and are case sensitive.

%SCREEN is always set to on or off. Try ...

Task
A1: Flash [ Text:Set Long:Off ] If [ %SCREEN Set ]
A2: Flash [ Text:!Set Long:Off ] If [ %SCREEN !Set ]
A3: Flash [ Text:~ on Long:Off ] If [ %SCREEN ~ on ]
A4: Flash [ Text:eq on Long:Off ] If [ %SCREEN eq on ]
A5: Flash [ Text:~ ON Long:Off ] If [ %SCREEN ~ ON ]
A6: Flash [ Text:eq ON Long:Off ] If [ %SCREEN eq ON ]

... Thom
 
eq works fine for me, but whats the difference between equals and matches?
I use equals when comparing numbers or numerical expressions and matches when comparing strings (including pattern matching as Thom mentioned)

Also, when is a variable !SET? When its completely empty?
Built in variables are always set.
User variables are set at the time you assign thenm a value. (I'm not sure if there's a way to create an uninitialzed variable except perhaps to reference a variable name that hasn't been assigned a value... never comes up in anything I do. I'm sure it has some purpose for advanced users, but not for me and I'd venture to say not for most beginner/intermediate tasker users.

So in summary the variables I work with are always set and I don't ever find a need to test if a variable is set... test the value with eq or matches instead.
 
Last edited:
Back
Top Bottom