FORUMS

Beats Music No Longer Accepting New Accounts

Whenever Apple launches a new product or service, it definitely manages to grab the … more

Do You Do Self-Repairs on Your Devices?

As smartphone designs become more and more complex, self-repairs on devices are also becoming … more

Sony Z4 Slips Out of Top 5 Smartphones in Japan

In a bid to streamline its flagship series which had been losing credibility over the … more

Sprint’s New Unlimited Plan with Ridiculous Capped Speeds

The carrier game in the United States is perpetually rushing forward at … more

need help with variable split

105 posts
Thanks Meter: 3
 
By cesar.maranhao, Senior Member on 24th August 2014, 12:35 PM
Post Reply Subscribe to Thread Email Thread
i am doing an automated weather forecast with tasker and already have the api for wunderground.

i managed to make several splits until i reduced the entire text to this (and here is my problem):

var2
<![CDATA[HERE COMES THE TEXT I WANT TASKER TO READ OUT LOUD]]>

the problem is that i cannot break this the way i want it. if i do not give an argument in spliter, it divides like this:

var21
<![CDATA[HERE

var 22
COMES

var3
THE

var23
etc

when i set tasker to read, it reads everything and it goes like

"less than CDATA Here comes the..........greater than"

i really need to break that piece of information but if i set the splitter argument to <![CDATA[> it maintains it there and the variable after the split result is the same.

var21
<![CDATA[HERE COMES THE TEXT I WANT TASKER TO READ OUT LOUD]]>

which is exactly the same as var2

is almost like i cannot remove it. any tips?
Last edited by cesar.maranhao; 24th August 2014 at 12:39 PM.
 
 
24th August 2014, 01:07 PM |#2  
Recognized Contributor
Thanks Meter: 1,323
 
More
Try Variable Section action.
The Following User Says Thank You to Aerowinder For This Useful Post: [ View ]
24th August 2014, 03:15 PM |#3  
OP Senior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by Aerowinder

Try Variable Section action.

i tried it, it solved part of the problem. thanks

now i only have to find a way to eliminate the > at the end

(this is because the text i get does not have a fixed number of characters)
Last edited by cesar.maranhao; 24th August 2014 at 04:06 PM.
24th August 2014, 04:29 PM |#4  
Recognized Contributor
Thanks Meter: 1,323
 
More
Quote:
Originally Posted by cesar.maranhao

i tried it, it solved part of the problem. thanks

now i only have to find a way to eliminate the > at the end

(this is because the text i get does not have a fixed number of characters)

Give me the entire string you are pulling from WU. I'll plug it in and do some tests.
24th August 2014, 09:50 PM |#5  
OP Senior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by Aerowinder

Give me the entire string you are pulling from WU. I'll plug it in and do some tests.

there you go.. how do you think i can do this? i have put in bold a small segment i want to retrieve

Quote:

<response>
<version>0.1</version>
<termsofService>http://www.wunderground.com/weather/api/d/terms.html</termsofService>
<features>
<feature>forecast</feature>
</features>
<forecast>
<txt_forecast>
<date>8:18 PM WEST</date>
<forecastdays>
<forecastday>
<period>0</period>
<icon>clear</icon>
<icon_url>http://icons.wxug.com/i/c/k/clear.gif</icon_url>
<title>Sunday</title>
<fcttext><![CDATA[Mainly clear. Lows overnight in the mid 50s.]]></fcttext>
<fcttext_metric><![CDATA[Mainly clear. Low 13C.]]></fcttext_metric>
<pop>0</pop>
</forecastday>
<forecastday>
<period>1</period>
<icon>nt_clear</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_clear.gif</icon_url>
<title>Sunday Night</title>
<fcttext><![CDATA[Clear skies. Low 54F. Winds NNW at 5 to 10 mph.]]></fcttext>
<fcttext_metric><![CDATA[Clear skies. Low 13C. Winds light and variable.]]></fcttext_metric>
<pop>0</pop>
</forecastday>
<forecastday>
<period>2</period>
<icon>clear</icon>
<icon_url>http://icons.wxug.com/i/c/k/clear.gif</icon_url>
<title>Monday</title>
<fcttext><![CDATA[Sunny skies. High near 75F. Winds NW at 5 to 10 mph.]]></fcttext>
<fcttext_metric><![CDATA[Sunny skies. High around 25C. Winds NW at 10 to 15 km/h.]]></fcttext_metric>
<pop>0</pop>
</forecastday>
<forecastday>
<period>3</period>
<icon>nt_mostlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_mostlycloudy.gif</icon_url>
<title>Monday Night</title>
<fcttext><![CDATA[Partly cloudy skies during the evening will give way to cloudy skies overnight. Low near 65F. Winds WNW at 5 to 10 mph.]]></fcttext>
<fcttext_metric><![CDATA[Partly cloudy during the evening followed by cloudy skies overnight. Low 18C. Winds WNW at 10 to 15 km/h.]]></fcttext_metric>
<pop>10</pop>
</forecastday>
<forecastday>
<period>4</period>
<icon>partlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/partlycloudy.gif</icon_url>
<title>Tuesday</title>
<fcttext><![CDATA[Cloudy early with partial sunshine expected late. High 76F. Winds WSW at 5 to 10 mph.]]></fcttext>
<fcttext_metric><![CDATA[Cloudy skies early, followed by partial clearing. High near 25C. Winds WSW at 10 to 15 km/h.]]></fcttext_metric>
<pop>20</pop>
</forecastday>
<forecastday>
<period>5</period>
<icon>nt_partlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_partlycloudy.gif</icon_url>
<title>Tuesday Night</title>
<fcttext><![CDATA[Partly to mostly cloudy. Low 66F. Winds light and variable.]]></fcttext>
<fcttext_metric><![CDATA[Partly to mostly cloudy. Low 18C. Winds light and variable.]]></fcttext_metric>
<pop>10</pop>
</forecastday>
<forecastday>
<period>6</period>
<icon>partlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/partlycloudy.gif</icon_url>
<title>Wednesday</title>
<fcttext><![CDATA[Considerable clouds early. Some decrease in clouds later in the day. High 76F. Winds W at 5 to 10 mph.]]></fcttext>
<fcttext_metric><![CDATA[Partly to mostly cloudy. High near 25C. Winds W at 10 to 15 km/h.]]></fcttext_metric>
<pop>20</pop>
</forecastday>
<forecastday>
<period>7</period>
<icon>nt_chancerain</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_chancerain.gif</icon_url>
<title>Wednesday Night</title>
<fcttext><![CDATA[Rain showers early with overcast skies late. Low 64F. Winds NW at 5 to 10 mph. Chance of rain 40%.]]></fcttext>
<fcttext_metric><![CDATA[Showers in the evening, then cloudy overnight. Low 18C. Winds WNW at 10 to 15 km/h. Chance of rain 40%.]]></fcttext_metric>
<pop>40</pop>
</forecastday>
</forecastdays>
</txt_forecast>
<simpleforecast>
<forecastdays>
<forecastday>
<date>
<epoch>1408903200</epoch>
<pretty_short>7:00 PM WEST</pretty_short>
<pretty>7:00 PM WEST on August 24, 2014</pretty>
<day>24</day>
<month>8</month>
<year>2014</year>
<yday>235</yday>
<hour>19</hour>
<min>00</min>
<sec>0</sec>
<isdst>1</isdst>
<monthname>August</monthname>
<monthname_short>Aug</monthname_short>
<weekday_short>Sun</weekday_short>
<weekday>Sunday</weekday>
<ampm>PM</ampm>
<tz_short>WEST</tz_short>
<tz_long>Europe/Lisbon</tz_long>
</date>
<period>1</period>
<high>
<fahrenheit>69</fahrenheit>
<celsius>20</celsius>
</high>
<low>
<fahrenheit>54</fahrenheit>
<celsius>12</celsius>
</low>
<conditions>Clear</conditions>

<icon>clear</icon>
<icon_url>http://icons.wxug.com/i/c/k/clear.gif</icon_url>
<skyicon></skyicon>
<pop>0</pop>
<qpf_allday>
<in>0.00</in>
<mm>0</mm>
</qpf_allday>
<qpf_day>
<in></in>
<mm></mm>
</qpf_day>
<qpf_night>
<in>0.00</in>
<mm>0</mm>
</qpf_night>
<snow_allday>
<in>0.0</in>
<cm>0.0</cm>
</snow_allday>
<snow_day>
<in></in>
<cm></cm>
</snow_day>
<snow_night>
<in>0.0</in>
<cm>0.0</cm>
</snow_night>
<maxwind>
<mph>0</mph>
<kph>0</kph>
<dir></dir>
<degrees>0</degrees>
</maxwind>
<avewind>
<mph>0</mph>
<kph>0</kph>
<dir></dir>
<degrees>0</degrees>
</avewind>
<avehumidity>88</avehumidity>
<maxhumidity>0</maxhumidity>
<minhumidity>0</minhumidity>
</forecastday>

<forecastday>
<date>
<epoch>1408989600</epoch>
<pretty_short>7:00 PM WEST</pretty_short>
<pretty>7:00 PM WEST on August 25, 2014</pretty>
<day>25</day>
<month>8</month>
<year>2014</year>
<yday>236</yday>
<hour>19</hour>
<min>00</min>
<sec>0</sec>
<isdst>1</isdst>
<monthname>August</monthname>
<monthname_short>Aug</monthname_short>
<weekday_short>Mon</weekday_short>
<weekday>Monday</weekday>
<ampm>PM</ampm>
<tz_short>WEST</tz_short>
<tz_long>Europe/Lisbon</tz_long>
</date>
<period>2</period>
<high>
<fahrenheit>75</fahrenheit>
<celsius>24</celsius>
</high>
<low>
<fahrenheit>65</fahrenheit>
<celsius>18</celsius>
</low>
<conditions>Clear</conditions>

<icon>clear</icon>
<icon_url>http://icons.wxug.com/i/c/k/clear.gif</icon_url>
<skyicon></skyicon>
<pop>0</pop>
<qpf_allday>
<in>0.00</in>
<mm>0</mm>
</qpf_allday>
<qpf_day>
<in>0.00</in>
<mm>0</mm>
</qpf_day>
<qpf_night>
<in>0.00</in>
<mm>0</mm>
</qpf_night>
<snow_allday>
<in>0.0</in>
<cm>0.0</cm>
</snow_allday>
<snow_day>
<in>0.0</in>
<cm>0.0</cm>
</snow_day>
<snow_night>
<in>0.0</in>
<cm>0.0</cm>
</snow_night>
<maxwind>
<mph>10</mph>
<kph>16</kph>
<dir>NW</dir>
<degrees>313</degrees>
</maxwind>
<avewind>
<mph>9</mph>
<kph>14</kph>
<dir>NW</dir>
<degrees>313</degrees>
</avewind>
<avehumidity>67</avehumidity>
<maxhumidity>0</maxhumidity>
<minhumidity>0</minhumidity>
</forecastday>

<forecastday>
<date>
<epoch>1409076000</epoch>
<pretty_short>7:00 PM WEST</pretty_short>
<pretty>7:00 PM WEST on August 26, 2014</pretty>
<day>26</day>
<month>8</month>
<year>2014</year>
<yday>237</yday>
<hour>19</hour>
<min>00</min>
<sec>0</sec>
<isdst>1</isdst>
<monthname>August</monthname>
<monthname_short>Aug</monthname_short>
<weekday_short>Tue</weekday_short>
<weekday>Tuesday</weekday>
<ampm>PM</ampm>
<tz_short>WEST</tz_short>
<tz_long>Europe/Lisbon</tz_long>
</date>
<period>3</period>
<high>
<fahrenheit>76</fahrenheit>
<celsius>24</celsius>
</high>
<low>
<fahrenheit>66</fahrenheit>
<celsius>19</celsius>
</low>
<conditions>Partly Cloudy</conditions>

<icon>partlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/partlycloudy.gif</icon_url>
<skyicon></skyicon>
<pop>20</pop>
<qpf_allday>
<in>0.00</in>
<mm>0</mm>
</qpf_allday>
<qpf_day>
<in>0.00</in>
<mm>0</mm>
</qpf_day>
<qpf_night>
<in>0.00</in>
<mm>0</mm>
</qpf_night>
<snow_allday>
<in>0.0</in>
<cm>0.0</cm>
</snow_allday>
<snow_day>
<in>0.0</in>
<cm>0.0</cm>
</snow_day>
<snow_night>
<in>0.0</in>
<cm>0.0</cm>
</snow_night>
<maxwind>
<mph>10</mph>
<kph>16</kph>
<dir>WSW</dir>
<degrees>253</degrees>
</maxwind>
<avewind>
<mph>8</mph>
<kph>13</kph>
<dir>WSW</dir>
<degrees>253</degrees>
</avewind>
<avehumidity>81</avehumidity>
<maxhumidity>0</maxhumidity>
<minhumidity>0</minhumidity>
</forecastday>

<forecastday>
<date>
<epoch>1409162400</epoch>
<pretty_short>7:00 PM WEST</pretty_short>
<pretty>7:00 PM WEST on August 27, 2014</pretty>
<day>27</day>
<month>8</month>
<year>2014</year>
<yday>238</yday>
<hour>19</hour>
<min>00</min>
<sec>0</sec>
<isdst>1</isdst>
<monthname>August</monthname>
<monthname_short>Aug</monthname_short>
<weekday_short>Wed</weekday_short>
<weekday>Wednesday</weekday>
<ampm>PM</ampm>
<tz_short>WEST</tz_short>
<tz_long>Europe/Lisbon</tz_long>
</date>
<period>4</period>
<high>
<fahrenheit>76</fahrenheit>
<celsius>24</celsius>
</high>
<low>
<fahrenheit>64</fahrenheit>
<celsius>18</celsius>
</low>
<conditions>Partly Cloudy</conditions>

<icon>partlycloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/partlycloudy.gif</icon_url>
<skyicon></skyicon>
<pop>20</pop>
<qpf_allday>
<in>0.00</in>
<mm>0</mm>
</qpf_allday>
<qpf_day>
<in>0.00</in>
<mm>0</mm>
</qpf_day>
<qpf_night>
<in>0.00</in>
<mm>0</mm>
</qpf_night>
<snow_allday>
<in>0.0</in>
<cm>0.0</cm>
</snow_allday>
<snow_day>
<in>0.0</in>
<cm>0.0</cm>
</snow_day>
<snow_night>
<in>0.0</in>
<cm>0.0</cm>
</snow_night>
<maxwind>
<mph>10</mph>
<kph>16</kph>
<dir>W</dir>
<degrees>268</degrees>
</maxwind>
<avewind>
<mph>8</mph>
<kph>13</kph>
<dir>W</dir>
<degrees>268</degrees>
</avewind>
<avehumidity>78</avehumidity>
<maxhumidity>0</maxhumidity>
<minhumidity>0</minhumidity>
</forecastday>

</forecastdays>
</simpleforecast>
</forecast>

Last edited by cesar.maranhao; 24th August 2014 at 09:53 PM.
24th August 2014, 11:34 PM |#6  
Recognized Contributor
Thanks Meter: 1,323
 
More
Quote:
Originally Posted by cesar.maranhao

there you go.. how do you think i can do this? i have put in bold a small segment i want to retrieve

If Tasker supports RegEx, that would be the way to do it. But I don't know if it does, so I'll assume it does not.


The layout is basic XML. You want <fcttext_metric> that is nested inside the first <forecastday> Try using <fcttext_metric><![CDATA[ as a splitter. And then </fcttext_metric> as another splitter. That should leave you with nothing but the text. So if you had an array, your information should be in arr1, arr3, arr5, arrX.
Last edited by Aerowinder; 24th August 2014 at 11:36 PM.
25th August 2014, 09:17 PM |#7  
OP Senior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by Aerowinder

If Tasker supports RegEx, that would be the way to do it. But I don't know if it does, so I'll assume it does not.


The layout is basic XML. You want <fcttext_metric> that is nested inside the first <forecastday> Try using <fcttext_metric><![CDATA[ as a splitter. And then </fcttext_metric> as another splitter. That should leave you with nothing but the text. So if you had an array, your information should be in arr1, arr3, arr5, arrX.

it did not work. when i use <fcttext_metric><![CDATA[ as a splitter it does not recognise the end result.

the original text is set as local variable %forecast

when i proceed with the variable split with that input and use flash %forecast2, the result is %forecast2

what am i doing wrong?
25th August 2014, 11:54 PM |#8  
Recognized Contributor
Thanks Meter: 1,323
 
More
Quote:
Originally Posted by cesar.maranhao

it did not work. when i use <fcttext_metric><![CDATA[ as a splitter it does not recognise the end result.

the original text is set as local variable %forecast

when i proceed with the variable split with that input and use flash %forecast2, the result is %forecast2

what am i doing wrong?

Ok, got it working.

The original XML response from the server, the one that you gave me, will be %forecast.

Variable Set: %forecast; To: <long response here>
Variable Split: %forecast; Splitter: <fcttext><![CDATA[
Varialbe Split: %forecast2; Splitter: ]]></fcttext>

Your info is now in %forecast21. After doing this, I see you wanted the metric read out. Same thing, just add _metric to the splits as per the XML file.

A little explanation for how the Splitter is working. It takes %forecast, and splits it into multiple parts. %forecast1, %forecast2, %forecast3, %forecast4, etc. For as many splits as it will find, it will keep incrementing the number. Through trial and error, we find the information that you desire is in %forecast2. I tested this by using Tasker to Flash: %forecast2. It creates a toast with the variable's value.

So now that we know we want %forecast2, we need to split it again. So we did. And we can't forget to increment. %forecast21, %forecast22, %forecast23, etc.

Again, by Flash, we can see that the information we want is in %forecast21.

Any questions?
The Following User Says Thank You to Aerowinder For This Useful Post: [ View ]
26th August 2014, 11:37 PM |#9  
OP Senior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by Aerowinder

Ok, got it working.

The original XML response from the server, the one that you gave me, will be %forecast.

Variable Set: %forecast; To: <long response here>
Variable Split: %forecast; Splitter: <fcttext><![CDATA[
Varialbe Split: %forecast2; Splitter: ]]></fcttext>

Your info is now in %forecast21. After doing this, I see you wanted the metric read out. Same thing, just add _metric to the splits as per the XML file.

A little explanation for how the Splitter is working. It takes %forecast, and splits it into multiple parts. %forecast1, %forecast2, %forecast3, %forecast4, etc. For as many splits as it will find, it will keep incrementing the number. Through trial and error, we find the information that you desire is in %forecast2. I tested this by using Tasker to Flash: %forecast2. It creates a toast with the variable's value.

So now that we know we want %forecast2, we need to split it again. So we did. And we can't forget to increment. %forecast21, %forecast22, %forecast23, etc.

Again, by Flash, we can see that the information we want is in %forecast21.

Any questions?

Thanks. I was setting the splitter the wrong way. It is now working properly. Cheers
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes