List dialogue: option to output index of selected items

224 views
Skip to first unread message

Daniel D

unread,
Apr 1, 2020, 4:40:19 PM4/1/20
to Tasker
Hello João,

I've tried to use the List Dialogue action to limit some tasks to specific members of an array and I have stumbled into the following problem:
Currently  the output of this action is an array containing the text of the items that were selected. problem is that if one of the items contains a comma, the resulting array is not really consistent. I've encountered this issue when using AutoWeb with Spotify API component that outputs an array containing the names of an album's songs and one of the songs contains a comma.

Going a bit deeper down the rabbit's hole without opening a new topic, I have the impression that the arrays that are created by the web API's kind of mess up with Tasker's arrays.
For example, as far as I've noticed, Tasker doesn't let the user create %Array1 = Two, Three. But AutoWeb would be able to output something lile %song_names= One, Two, Three, Four, where "Two, Three" is actually the name of one song, so %song_names2 = Two, Three. 
From these observations I feel that some mitigation might be needed. Maybe the choice of comma as an array separator was not the best (I know, it was made years ago, by Pent, when these kind of situations were unimaginable). Maybe the default separator of arrays should be changed or at least the user should be given the option to choose it. I don't know...

Thanks!

PS: I've tried to give an actual example and this is the result:

Task:

     A1: AutoWeb Authentication [ Configuration:Web Service: Spotify Timeout (Seconds):60 ]
     A7: AutoWeb Web Service [ Configuration:API: Spotify
    API Action: Get album tracks
    Market: DE
    Id: 74ydDCcXTco741y42ceRJ5 Timeout (Seconds):120 ]
    A8: Array Set [ Variable Array:%Arrays Values:%items_name() Splitter: ] 

Resulting variables:

Screenshot_20200401-223533.jpg



Here is the actual track listing for reference: https://en.wikipedia.org/wiki/Reise,_Reise#Track_listing

Rich D

unread,
Apr 1, 2020, 5:47:45 PM4/1/20
to Tasker Google Groups Post
It is not the array elements that is the issue it is the way you are using/viewing them. The %array()  is just listing  the elements and happens to use a comma as a separator. You can use the variable join action to set your own separator. So in your example do this. 


     A1: AutoWeb Authentication [ Configuration:Web Service: Spotify Timeout (Seconds):60 ]
     A7: AutoWeb Web Service [ Configuration:API: Spotify
    API Action: Get album tracks
    Market: DE
    Id: 74ydDCcXTco741y42ceRJ5 Timeout (Seconds):120 ]

A8: Variable Join %items_name ; Joiner: <>

    A8: Array Set [ Variable Array:%Arrays Values:%items_name Splitter: <> ] 

Rich D

unread,
Apr 1, 2020, 6:00:57 PM4/1/20
to Tasker Google Groups Post
The same holds true for the list dialog action. The ID names are in the array %ld_selected.   To list the array elements you can use %ld_selected(), However that will use a comma to separate each array item.  Try this example. Run it then check the variables tab.

    Join (888)
    A1: Array Set [ Variable Array:%myarray Values:1,2<>345,6<>789,7,8 Splitter:<> ] 
    A2: List Dialog [  Mode:Multiple Choices Title:test Items:%myarray Selected Items: Long Click Task: Button 1: Button 2: Button 3: Timeout (Seconds):30 Use HTML:Off First Visible Index:1 Hide Filter:Off ] 
    A3: Variable Join [ Name:%ld_selected Joiner:<> Delete Parts:Off ] 
    A4: Array Set [ Variable Array:%Test_array Values:%ld_selected Splitter:<> ] 
    




You should try to refrain from creating global arrays. They can quickly add many global variables to your tasker data. Global variables require a lot of overhead. 


Reply all
Reply to author
Forward
0 new messages