Array pop help. Want to pop last line in array.

386 views
Skip to first unread message

John Day

unread,
Jul 28, 2014, 3:51:42 PM7/28/14
to tas...@googlegroups.com
I am trying to figure out how I can pop the Last entry in an array. The problem is the list could be any size and the Array pop command wants a static position and will not accept a variable position such as #< since I don't know what the last position will be I don't know how to pop it. Anyone have an idea how to do this? Thanks in advance

Matt R

unread,
Jul 28, 2014, 4:12:37 PM7/28/14
to tas...@googlegroups.com
Max out the position number (I think 999999).  That will remove the last element (unless your array is longer than 999999 elements...).

Matt

Brandon Horwath

unread,
Jul 28, 2014, 4:29:41 PM7/28/14
to tas...@googlegroups.com
I could be wrong, but set variable %pop to %array(#), and pop position %pop.

%pop should equal the last index number of the array.

Rich D

unread,
Jul 28, 2014, 4:44:25 PM7/28/14
to Tasker Google Groups Post

> I could be wrong

Close...

From the guide..

%arr(#)
The number of defined array elements (4 in this case)
%arr(#>)
The index of the first defined array element, or 0 if none are defined (1).
%arr(#<)
The index of the last defined array element, or 0 if none are defined (4)

, but set variable %pop to %array(#), and pop position %pop.
>

So to do it this way I think you need..

%arr(#<)















Brandon Horwath

unread,
Jul 28, 2014, 4:56:32 PM7/28/14
to tas...@googlegroups.com
Hmm. That sounds right.

I though %arr(#) would always equal %arr(#<), but maybe empty indexs are counted with one and not the other.

Brandon Horwath

unread,
Jul 28, 2014, 4:59:51 PM7/28/14
to tas...@googlegroups.com
Yep. I see. Defined vs. Last.

Rich D

unread,
Jul 28, 2014, 5:24:25 PM7/28/14
to Tasker Google Groups Post


> Yep. I see. Defined vs. Last.
>

I would recommend Matt's suggestion ( he usually has a good reason for the approach he chooses) I have not tested this but to use  %arr(#<) in the pop action you might need to set it to a local variable first..   :)

John Day

unread,
Jul 28, 2014, 5:36:24 PM7/28/14
to tas...@googlegroups.com
"but set variable %pop to %array(#), and pop position %pop."

As far as I can tell it will only accept a number such as 1 or 39 or 999 it wont let me use a variable for the position hence my deli-ma. 


On Mon, Jul 28, 2014 at 4:24 PM, Rich D <ricp...@gmail.com> wrote:


> Yep. I see. Defined vs. Last.
>

I would recommend Matt's suggestion ( he usually has a good reason for the approach he chooses) I have not tested this but to use  %arr(#<) in the pop action you might need to set it to a local variable first..   :)

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/pgV32u3SJPA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Jeremy Harris

unread,
Jul 28, 2014, 5:39:24 PM7/28/14
to tas...@googlegroups.com
I use this a lot...

Lots of ways to skin a cat with tasker, but I do:

Var Set %last to %arr(#<)
Array Pop %arr(%last)

As was suggested a few times. It works. I agree with Rich though...Matt usually has the best approach.

Robert Hansen

unread,
Jul 28, 2014, 5:44:16 PM7/28/14
to tas...@googlegroups.com

Sounds like beginner mode may be enabled. If so, Menu > Preferences > UI Tab > Beginner mood uncheck.

You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.

John Day

unread,
Jul 28, 2014, 7:08:04 PM7/28/14
to tas...@googlegroups.com
Great will give these Ideas a try thanks for all the help

Brandon Horwath

unread,
Jul 28, 2014, 7:22:45 PM7/28/14
to tas...@googlegroups.com
If you can't use a variable (by selecting the 'alternate' icon above the field [not present]) then yes, disable beginner mode.

John Day

unread,
Jul 28, 2014, 8:54:31 PM7/28/14
to tas...@googlegroups.com
I dont have beginner mode on, just saw it will let me press the icon and select a variable but will not let me type the variable by hand.  Weird but the is away around it thanks again for the info.


On Mon, Jul 28, 2014 at 6:22 PM, Brandon Horwath <brandon...@gmail.com> wrote:
If you can't use a variable (by selecting the 'alternate' icon above the field [not present]) then yes, disable beginner mode.

Rich D

unread,
Jul 28, 2014, 9:32:34 PM7/28/14
to Tasker Google Groups Post


> I dont have beginner mode on, just saw it will let me press the icon and select a variable but will not let me type the variable by hand.

Can not recall the exact reason for this but I do believe it is the way it is supposed to be.  

Weird but the is away around it

Yes.
1. Use Matt's suggestion and set it to 99999

2. Use Jeremy's suggestion and set a local variable to %arr(#>) then use that variable in the pop action.

John Day

unread,
Jul 28, 2014, 11:08:48 PM7/28/14
to tas...@googlegroups.com
got it. works good on to the next step THANKS GUYS!


--
Reply all
Reply to author
Forward
0 new messages