Checking empty array variable set by Autoinput

160 views
Skip to first unread message

chris Klein

unread,
Mar 12, 2021, 6:29:49 PM3/12/21
to Tasker
doing some reading and I see a few ways.  

My arrays are populated with UI Query autoinput, and I want to check if some element was never set by my UI Query.

I have found 2 things people did online and just wondering if anyone knows which might work for me. thanks so much!

IF  %arr(%num)  ~R  ^\%.+$ 

If %arr(%num) ~R ^%.*

jmjc...@gmail.com

unread,
Mar 12, 2021, 9:12:25 PM3/12/21
to Tasker
If this is related to your other task, I will suggest this:

First, reset all arrays returned by AI Query before you use the Query action again. The action doesn't reset arrays for you. For example, if 5 elements are returned in the first run, and 3 elements are returned in the 2nd run, you will still see 5 elements in the second run, 3 from the 2nd run and 2 left behind from the 1st.

Second, check the Continue after Error option in the Query action. If the action doesn't return anything, %errmssg will show "timeout" and you will know the action failed.

And to answer your question above if it is not related to your task, you can simply do a %arr(%num) ISN'T SET.

chris Klein

unread,
Mar 13, 2021, 5:12:50 PM3/13/21
to Tasker
hey yes it is but after doing some research I think this needed its own topic and maybe can help others.

here is what I did which seemed to work so far

if %variable(%arraynum) ~R ^%.*
   clear all variables
GoTo Toploop


and I set a notification when it finds a void variable because of how the app refreshes so fast, and the UIquery catches it in between. So now I can see it catch a void variable and then boom it just restarts over again!!!!!!

I am so excited!

JMJC you are the best!!!!!!  you literally walked me through the debug process and taught me how I can figure out the problem!

I can't thank you enough, honestly!

Rich D

unread,
Mar 13, 2021, 6:11:37 PM3/13/21
to Tasker Google Groups Post


On Fri, Mar 12, 2021, 9:12 PM jmjc...@gmail.com  you can simply do a %arr(%num) ISN'T SET.


I would be cautious about using that approach. I know for a fact that sometimes that test will return a false positive and I believe variables returned from plug-ins are susceptible to this issue. Since discovering this long ago I have always used the escape character to test for unset variables

If %my_var(%num) matches \%myvar(%num)

That one has never failed me.. 

jmjc...@gmail.com

unread,
Mar 13, 2021, 8:48:52 PM3/13/21
to Tasker
You are welcome. So rewarding when you figured it out yourself!
Reply all
Reply to author
Forward
0 new messages