Re: Array clear

144 views
Skip to first unread message

Raul SC

unread,
Jul 31, 2017, 9:29:03 PM7/31/17
to tas...@googlegroups.com
Hello

Is there any way to remove arrays following a certain number?

For example, delete %array(100:)

Rich D

unread,
Aug 2, 2017, 5:17:41 AM8/2/17
to Tasker Google Groups Post


Is there any way to remove arrays following a certain number?

For example, delete %array(100:)

No direct action for this.

You can section an array like this.

Array Delete (217)
A1: Array Set [ Variable Array:%test Values:A,b,c,d,e,f Splitter:, ] 
A2: Array Set [ Variable Array:%section Values:%test(1:3) Splitter:, ] 
A3: Array Clear [ Variable Array:%test ] 
A4: Flash [ Text:%section() Long:On ] 




Raul SC

unread,
Aug 2, 2017, 7:22:39 AM8/2/17
to Tasker
What a good idea, I would never have thought of it. Thank you very much, it works perfectly.

WH_Array Clear
A1: Establecer variable [ Nombre:%section A:%WH_Habilitados(:50) Recurse Variables:Apagado Calcular:Apagado Añadir:Apagado ]
A2: Separar variable [ Nombre:%section Separador:, Eliminar base:Apagado ]
A3: Establecer variable [ Nombre:%WH_Habilitados A:%section Recurse Variables:Apagado Calcular:Apagado Añadir:Apagado ]
A4: Separar variable [ Nombre:%WH_Habilitados Separador:, Eliminar base:Apagado ]

Raul SC

unread,
Aug 2, 2017, 9:39:12 AM8/2/17
to Tasker
The solution that Richi D has given, works perfectly in most cases, but in my case, when I separated the variable with "," it caused me errors, due to which some arrays contained "," and were sectioned.

So I came up with one of the new Tasker options: (use regex in any of the places where you could only use Tasker pattern matching)

In my case I wanted to delete all arrays greater than 99.

So I do the following:

A1: Clear Variable [Name: ~R%WH_Log\d\d\d Pattern Matching:ON Local Variables Only: Off]

This way I get all the% WH_Log arrays with more than two digits deleted.

I share it, in case it serves someone else, a greeting.

Rich D

unread,
Aug 2, 2017, 10:06:01 AM8/2/17
to Tasker Google Groups Post


> The solution that Richi D has given, works perfectly in most cases, but in my case, when I separated the variable with "," it caused me errors, due to which some arrays contained "," and were sectioned.

Ahh, forgot about that.. :(  It would be nice if we could define the splitter used when getting the data from the array with a %arr().  Maybe pent could make so we could do %arr()(|)  so this would present the data like a|b|c|d

>
> So I came up with one of the new Tasker options: (use regex in any of the places where you could only use Tasker pattern matching)
>

Great idea..

> In my case I wanted to delete all arrays greater than 99.

I am not a regex guy but could you not also come up with a regex that would match all numbers greater then 99,  or even any group of numbers like 24-48 ? For others interested in this.

Raul SC

unread,
Aug 2, 2017, 10:28:55 AM8/2/17
to Tasker
I'm sorry, google does not translate your answer correctly and I'm not sure if I understand you correctly.

Each \d is a digit, so the regular expression %Var\d\d\d will only match the arrays greater than 99. To match, it must be a three-digit array, and in no case will match With an array of one or two digits.

Reply all
Reply to author
Forward
0 new messages