It is currently April 24th, 2024, 11:42 pm

Basic StringIndex Help

Get help with creating, editing & fixing problems with skins
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Basic StringIndex Help

Post by csm725 »

What is StringIndex and you do I use and utilize it? :?:
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Basic StringIndex Help

Post by JpsCrazy »

StringIndex is used with WebParser.
If you are extracting data from it (which I would assume you would be) it tells the RegExp which part you want.

An example:

Code: Select all

;--Get Images-------
[msImageLinks]
	Measure=Plugin
	Plugin=Plugins/WebParser.dll
	UpdateRate=43200000
	Url=http://www.postsecret.com/feeds/posts/default?alt=rss
	RegExp="(?siU)catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*catch\(e\) \{\}" href="(.*)"&gt.*"

[msImage1]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=1
Download=1
DownloadFile=1.jpg

[msImage2]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=2
Download=1
DownloadFile=2.jpg

[msImage3]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=3
Download=1
DownloadFile=3.jpg

[msImage4]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=4
Download=1
DownloadFile=4.jpg

[msImage5]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=5
Download=1
DownloadFile=5.jpg

[msImage6]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=6
Download=1
DownloadFile=6.jpg

[msImage7]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=7
Download=1
DownloadFile=7.jpg

[msImage8]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=8
Download=1
DownloadFile=8.jpg

[msImage9]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=9
Download=1
DownloadFile=9.jpg

[msImage10]
Measure=Plugin
Plugin=Plugins/WebParser.dll
Url=[msImageLinks]
StringIndex=10
Download=1
DownloadFile=10.jpg
So in the Main RegExp in the top measure there's a lot of () (Specifically the (.*) if you can't find it in that mess of code.). Those tell Rainmeter what data you want from the website.
Now, when you use [msImageLinks] (The main measure) as the url in another webparser measure it retains the same information. String Index determines which () you're taking info from.
In this example, it's downloading images from PostSecret.com
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Basic StringIndex Help

Post by csm725 »

So if the RegExp returns more than one value, the StringIndex is used to access the different values?
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Basic StringIndex Help

Post by JpsCrazy »

csm725 wrote:So if the RegExp returns more than one value, the StringIndex is used to access the different values?
More or less.
I am no expert on RegExp, so if someone could confirm this for me:
If you have one set of () in your RegExp, you just get data for the first one no matter how many times it matches something. (I'm not sure, but I don't believe you need StringIndex if you're using one () of those.)
If you have many sets of () it determines which one a specific measure is using.
If you have more sets of () than data, the RegExp breaks. (Unless there's some tweaking done to it.)

Try using JSMorley's RainRegExp add on, and mess around with some parsing.
If you did it correctly, you should get values at the bottom such as
1= Some data
2= More data
etc
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Basic StringIndex Help

Post by csm725 »

Okay, I get it now.