> Profile: Stealth Mode (13)
> State: Variable Value [ Name:%Theft_Detected Op:Matches Value:1 ]
> Enter: Anon (14)
> A1: Variable Set [ Name:%leave_enabled To:Boot Check,Incoming SMS Check,Stealth Mode Do Maths:Off Append:Off ]
> A2: Variable Split [ Name:%leave_enabled Splitter:, Delete Base:Off ]
> A3: Variable Set [ Name:%enabled_profiles To:%PENABLED Do Maths:Off Append:Off ]
> A4: Variable Split [ Name:%enabled_profiles Splitter:, Delete Base:Off ]
> A5: Array Pop [ Variable:%enabled_profiles Position:1 To Var: ]
> A6: For [ Variable:%current_profile Items:%enabled_profiles() ]
> A7: For [ Variable:%temp Items:%leave_enabled() ]
> A8: If [ %current_profile ~ %temp ]
> A9: Variable Set [ Name:%skip To:1 Do Maths:Off Append:Off ]
> A10: Goto [ Type:End of Loop Number:1 Label: ]
> A11: End If
> A12: End For
> A13: Flash [ Text:%current_profile Long:Off ]
> A14: If [ %skip = 1 ]
> A15: Variable Set [ Name:%skip To:0 Do Maths:Off Append:Off ]
> A16: Goto [ Type:Top of Loop Number:1 Label:outer_loop ]
> A17: End If
> A18: [X] Profile Status [ Name:%current_profile Set:Off ]
> A19: End For
>
I have not used the 'goto "top of loop"' action before so I am not sure why you get the endless loop but i do have a few suggestions to simplify things..
1. The for loop will work fine with just a comma separated list in the variable. So I think you could just do it with one for loop based on the %PENABLED
A6: For [ Variable:%current_profile Items:%PENABLED ]
and to check for profiles to remain active just do a
Profile status off ; If %leave_enabled does not match *,%current_profile,*
You will need to add a comma before the first profile name (Boot Check) in this variable set action..
> A1: Variable Set [ Name:%leave_enabled To:,Boot Check,Incoming SMS Check,Stealth Mode Do Maths:Off Append:Off ]
Rich...
> Profile: Stealth Mode (13)
> State: Variable Value [ Name:%Theft_Detected Op:Matches Value:1 ]
> Enter: Anon (14)
> A1: Variable Set [ Name:%leave_enabled To:Boot Check,Incoming SMS Check,Stealth Mode Do Maths:Off Append:Off ]
> A2: Variable Split [ Name:%leave_enabled Splitter:, Delete Base:Off ]
> A3: Variable Set [ Name:%enabled_profiles To:%PENABLED Do Maths:Off Append:Off ]
> A4: Variable Split [ Name:%enabled_profiles Splitter:, Delete Base:Off ]
> A5: Array Pop [ Variable:%enabled_profiles Position:1 To Var: ]
> A6: For [ Variable:%current_profile Items:%enabled_profiles() ]
> A7: For [ Variable:%temp Items:%leave_enabled() ]
> A8: If [ %current_profile ~ %temp ]
> A9: Variable Set [ Name:%skip To:1 Do Maths:Off Append:Off ]
> A10: Goto [ Type:End of Loop Number:1 Label: ]
> A11: End If
> A12: End For
> A13: Flash [ Text:%current_profile Long:Off ]
> A14: If [ %skip = 1 ]
> A15: Variable Set [ Name:%skip To:0 Do Maths:Off Append:Off ]
> A16: Goto [ Type:Top of Loop Number:1 Label:outer_loop ]
> A17: End If
> A18: [X] Profile Status [ Name:%current_profile Set:Off ]
> A19: End For
>
> Anyone has any idea where my error is?
I think the problem is that the 'goto top of loop' is going to A7 not A6 as you expect. From the user guide...
Top of Loop: jump to the "first" For action above the current action ('continue')
Rich...
I have not used the 'goto "top of loop"' action before so I am not sure why you get the endless loop but i do have a few suggestions to simplify things..
1. The for loop will work fine with just a comma separated list in the variable. So I think you could just do it with one for loop based on the %PENABLED
A6: For [ Variable:%current_profile Items:%PENABLED ]
and to check for profiles to remain active just do a
Profile status off ; If %leave_enabled does not match *,%current_profile,*
You will need to add a comma before the first profile name (Boot Check) in this variable set action..
> A1: Variable Set [ Name:%leave_enabled To:,Boot Check,Incoming SMS Check,Stealth Mode Do Maths:Off Append:Off ]
Rich...
Possibly there are other problems, but I tested a simple For with a
Goto (Top Of Loop) and
it's definitely not working correctly (it doesn't increment to the
next item in the For as 'continue'
would - since it's described as 'like continue' in the help text, I'm
pretty sure that's unintended).
I can see why it's happening but don't want to fix it till after the
current beta has been released
as stable (otherwise I have to build another beta release because it's
tricky code). Sorry for the delay!
Pent
I couldn't get it to work exactly as you described, because it seems that the For action takes %PENABLED as a single entry in its comma-separated list of items to loop through, instead of looking inside it and separating each profile. I suppose that's actually logical because this way you can actually have commas in the text of some iterations. Like for example, For [ Variable:%xxx Items:%PENABLED,apple,banana ] would run three times, once for ",Profile1,Profile2,...,Profile(n)", once for "apple" and once for "banana". So I still have to do a split on %PENABLED before putting it in the For action.
Sorry for any time you might have lost because of my incorrect information, I thought I had use a variable like that in a for loop but I must have been thinking of something else.. :(
You are of course correct in that a variable containing a comma separated list will not produce separate iterations in a for loop. Just to be clear for others a loop like this:
Forloop (78)
A1: Variable Set [ Name:%abc To:a,b,c,d,e,f Do Maths:Off Append:Off ]
A2: For [ Variable:%items Items:%abc ]
A3: Flash [ Text:%items Long:Off ]
A4: End For
Will result in one flash containing "a,b,c,d,e,f"
>
>
> A1: Variable Set [ Name:%leave_enabled To:Boot Check,Incoming SMS Check,Stealth Mode Do Maths:Off Append:Off ]
> A2: Variable Set [ Name:%enabled_profiles To:%PENABLED Do Maths:Off Append:Off ]
> A3: Variable Split [ Name:%enabled_profiles Splitter:, Delete Base:Off ]
> A4: Array Pop [ Variable:%enabled_profiles Position:1 To Var: ]
> A5: For [ Variable:%current_profile Items:%enabled_profiles() ]
> A6: If [ %leave_enabled !~ *%current_profile* ]
> A7: Profile Status [ Name:%current_profile Set:Off ]
> A8: Variable Set [ Name:%disabled_profiles To:,%current_profile Do Maths:Off Append:On ]
> A9: End If
> A10: End For
> A11: Write File [ File:Tasker/disabled_profiles.txt Text:%disabled_profiles Append:Off Add Newline:On ] If [ %disabled_profiles Is Set ]
>
The only problem I see with it now is I believe it will fail if you have two separate profile names such as "Power" and "Power Off". If you put "Power" in %leave_enabled it will leave both "Power" And "Power Off" enabled.
Using *,%current_profile,* As the search criteria Will prevent this, You just need to make sure that %leave_enabled has a comma in the beginning and the end of it.
Rich..
The only problem I see with it now is I believe it will fail if you have two separate profile names such as "Power" and "Power Off". If you put "Power" in %leave_enabled it will leave both "Power" And "Power Off" enabled.
Using *,%current_profile,* As the search criteria Will prevent this, You just need to make sure that %leave_enabled has a comma in the beginning and the end of it.
Rich..