It is currently April 20th, 2024, 10:28 am

Getting over the substring limit?

Get help with creating, editing & fixing problems with skins
scub
Posts: 30
Joined: May 16th, 2015, 10:37 pm

Getting over the substring limit?

Post by scub »

i spent a good hour or so trying to figure out why my webparser regexp was failing.. after busting my brain i find that there is a limit of something like 100?

i mean for saving some local cpu cycles i can understand, but think my 12 core system can handle a 30KB webpage :D

how can i get over this limit without having to involve learning another programming language or over complicating things. i read about using Lua, but i know little to nothing about it, i have experience in php.

ideally, i would break up the webparser and make several calls, but i want to limit requests as i am using an API which has limits on number of calls, so i want to do it in one http request.

this is what i am after and it's failing..
the data is parsed in 3 parts. one entry of current weather conditions, ten entries of detailed 10 day forecast and ten entries of the 10 day weekly temperatures. the code would work if it wasn't for the string limit. i don't get what the fuss is all about. seems like a trivial amount to impose such restriction on something that runs every 15 mins and takes all but 2-3 seconds to process it. it would be nice if i could just download the xml data and somehow use rainmeter to fetch an array of the data, but my guess is it requires some other scripting knowledge which as ive noted earlier, is no bueno.

i've attached the xml of the weather data in case someone wants to help, it would be appreciated. i suppose it's a good thing i did not have plans to use all the weather data in the xml as rainmeter doesn't seem interested in being able to handle the little bit i want from it ;)

Code: Select all

GET_CURRENT=<display_location>.*<city>(.*)</city>.*<observation_time>Last Updated on (.*), (.*) (.*)</observation_time>.*<weather>(.*)</weather>.*<temp_f>(.*)</temp_f>.*<relative_humidity>(.*)</relative_humidity>.*<wind_string>(.*)</wind_string>.*<wind_dir>(.*)</wind_dir>.*<wind_degrees>(.*)</wind_degrees>.*<wind_mph>(.*)</wind_mph>.*<wind_gust_mph>(.*)</wind_gust_mph>.*<pressure_in>(.*)</pressure_in>.*<pressure_trend>(.*)</pressure_trend>.*<dewpoint_f>(.*)</dewpoint_f>.*<heat_index_string>(.*)</heat_index_string>.*<heat_index_f>(.*)</heat_index_f>.*<windchill_string>(.*)</windchill_string>

GET_FORECAST=(?(?=.*<period>).*<icon>(.*)</icon>.*<title>(.*)</title>.*<fcttext>(.*)</fcttext>.*<pop>(.*)</pop>)

GET_FUTURE=(?(?=.*<weekday>(.*)</weekday>).*<high>.*<fahrenheit>(.*)</fahrenheit>.*</high>.*<low>.*<fahrenheit>(.*)</fahrenheit>.*</low>.*<conditions>(.*)</conditions>.*<icon>(.*)</icon>)

RegExp="(?siU)#GET_CURRENT#
#GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST##GET_FORECAST#
#GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE##GET_FUTURE#"
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5398
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Getting over the substring limit?

Post by eclectic-tech »

Have a look in the manual at StringIndex2.
You'll have to rethink your RegExp's, but this gets around the 99 Substring limit... :thumbup:
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Getting over the substring limit?

Post by fonpaolo »

As a suggestion, the problem is not the limit per se, it's how much you want to over complicate a "simple task"... ;-)
Do you want to exceed the 99 substrings limit?
It's very easy and, maybe, also useful and clean:
- use a first WebParser measure to download all (it's saved on memory);
- create some other WebParser measures, using the first as source, to extract the sections you want/need (99 multiplied for every measure... it's enough?);
- then, add as many child measures as the data/strings/images/whatever you want to use.
scub
Posts: 30
Joined: May 16th, 2015, 10:37 pm

Re: Getting over the substring limit?

Post by scub »

i want to use the most efficient, and i guess simple method.

using eclectic method i came up with:

Code: Select all


GET_CURRENT=<display_location>.*<city>(.*)</city>.*</display_location>.*<observation_time>Last Updated on (.*), (.*) (.*)</observation_time>.*<weather>(.*)</weather>.*<temp_f>(.*)</temp_f>.*<relative_humidity>(.*)</relative_humidity>.*<wind_string>(.*)</wind_string>.*<wind_dir>(.*)</wind_dir>.*<wind_degrees>(.*)</wind_degrees>.*<wind_mph>(.*)</wind_mph>.*<wind_gust_mph>(.*)</wind_gust_mph>.*<pressure_in>(.*)</pressure_in>.*<pressure_trend>(.*)</pressure_trend>.*<dewpoint_f>(.*)</dewpoint_f>.*<heat_index_string>(.*)</heat_index_string>.*<heat_index_f>(.*)</heat_index_f>.*<windchill_string>(.*)</windchill_string>.*<windchill_f>(.*)</windchill_f>.*<feelslike_f>(.*)</feelslike_f>.*<visibility_mi>(.*)</visibility_mi>.*<UV>(.*)</UV>.*<precip_today_in>(.*)</precip_today_in>.*<icon>(.*)</icon>

ITEM=.*<forecastday>(.*)</forecastday>

RegExp="(?siU)
#GET_CURRENT#
.*<txt_forecast>#ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM#
.*<simpleforecast>#ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM##ITEM#"
so:
string index 1-24 (current weather condition values i want)
string index 25-35 (<txt_forecast> has ten <forecastday> entries of 10 day forecast)
string index 36-46 (<simpleforecast> has ten <forecastday> entries of 10 day temp forecast)

seems like the best way?
btw, how do i escape in rainmeter so i can have regexp syntax on new lines? easier to read when working on them.

thanks.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Getting over the substring limit?

Post by fonpaolo »

It's a good start, I don't know if it's a simplification or not, but, for example, for the "Last Updated" you can use only one capture for all (Day and time), then using substitution remove/modify or reformat the string to be displayed, so you can save some captures for other data.