Quick Tasker tip: Comma separated values and arrays are good friends

Variables in Tasker are hard enough to grasp already, and then arrays show up to make it even harder. That’s a pity, since both are vital for being able to create a lot of powerful Tasker creations. When dealing with arrays, however, it’s important to know that comma separated values play nice with arrays.

One of the most common ways of creating arrays is to use Variable Split. Sometimes you can’t control what you have to split by to do this, but if you use Variable Split to turn something you yourself stored in a text file or something like that into an array, commas are good splitters. While they do have the disadvantage of being common enough to possibly be used in your values without being intended as splitters (e.g. commas as part of a sentence in a joke for a random joke system), the advantage of using commas is that you can instantly turn an array into a comma separated list of values by using the %arr() feature. In other words, you can move between an array and a comma separated list of values with a single command each way, which can be very helpful. I originally stored my todo list items on news lines of a text file, but eventually moved onto a comma separated list because of this.

The %arr() feature is also useful in that it makes arrays and variables with comma separated values interchangeable in several places in Tasker. I’ve previously talked about how it’s advisable to use single variables with comma separated values instead of actual arrays in Menu scene elements, because global arrays are slow. The Menu scene element gladly accepts a single variable with comma separated values and treats it more or less like an array, turning each value into a separate list item. Another example where the two work more or less the same are For loops, where you can either input an array in the %arr() form, or just a variable with a comma separated list of values.

Using both of these also gives you more tools for manipulating data. Having a single variable allows you to use Variable Search Replace, which can be used for things like removing or changing several different words in one go, without having to do one at a time. Arrays on the other hand can be used to for instance find, remove, or change a dynamic part of your data based on knowing a static part of it. I use these two features in combination in the task to add items to my todo list with AutoVoice, which means I use both arrays and single variables to handle the same data. I use the above mentioned array feature to locate the word immediately preceding the word “list” in the voice command, and then I move the data to a single variable in order to use Variable Search Replace to get rid of several “filler words” in one go.

Some of the tools available for these two methods are also very similar. Variable Search Replace can often be used instead of Variable Pop, and using Variable Set with the Append option checked and a comma before the content (e.g. Variable Set %list to ,%item) can be used instead of Variable Push to add something to the end of a list. You can also Variable Search Replace words with commas to for instance turn a command that uses “and” to separate items into an actual comma separated list of values, a trick that’s useful for voice control.

There are countless examples of where these two methods are similar, but the point I’m trying to get across is that it’s important to be aware of both methods and that they are in fact similar. It can be tempting to pick a method and stick to it, as it somehow feels cleaner, but using the two together can give you some advantages you might not have known were there.

Share this:

About the Author

Andreas Ødegård was an associate editor at Pocketables. He’s more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets and tends to stick with his choice of device for a long time as a result of that. Currently that includes an iPad mini and a Samsung Galaxy S II.

RMH

Andreas, I’m trying to make my own version of a To-Do app and I’m having difficulty making my app notify me with a certain task on its respective due date. Do you think you can help me out? I’m assuming it will be easier for the both of us if its done through email. Let me know if you can help and I will send my email address. TIA

We are certified, trustworthy, reliable, efficient, dynamic, fast,
reliable,financier for real estate cooperate and all forms of business
processes
Will provide long term financing
The maximum loan Duration 5-30 years.
We offer this type of loan and much more:
* Personal Loans (unsecured loans)
* Business Loans (Unsecured Loan)
* Consolidation Loans
* The combination of credit
* Home Improvement

Please, if you are interested in our financial offer, please contact
us by e-mail:[email protected]

It is when we must take advantage, you will be prompted.
Our programs begin the process data in accordance with your loan Application.
Full Name :………………………..
Gender :………………………
Marital status :…………………….
Address :…………………..
ZIP / City :…………………….
Country :…………………….
Occupation :…………………
The required amount :…………………..
Duration :………………………..
Purpose of loan :………………….
Phone :…………………..
Thank you for your interest!
Subject:
Julian Smith.
(JRC / MD /)