From the Manual:
First, here is the entire code of a little skin to demonstrate how to use this feature. Go ahead and create this and run it to see it in action:StringIndex2
The second string index is used when using a RegExp in a measure that uses data from another webparser measure (i.e. the Url points to a measure and not to a real URL). In this case the StringIndex defines the index of the result of the other RegExp and the StringIndex2 defines the index of this measure's RegExp (i.e. it defines the string that the measure returns). If the RegExp is not defined in this measure the StringIndex2 has no effect.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Variables]
Item=.*<item>(.*)</item>
Sub="<![CDATA[":"","]]>":""
[MeasureSite]
Measure=Plugin
Plugin=WebParser
Url=http://feeds.gawker.com/lifehacker/full
RegExp="(?siU)<channel>.*<image>.*<title>(.*)</title>.*<link>(.*)</link>#Item##Item##Item#"
[MeasureMainTitle]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
StringIndex=1
Substitute=#Sub#
[MeasureMainLink]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
StringIndex=2
[MeasureItem1Title]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<title>(.*)</title>"
StringIndex=3
StringIndex2=1
Substitute=#Sub#
[MeasureItem1Link]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<link>(.*)</link>"
StringIndex=3
StringIndex2=1
[MeasureItem2Title]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<title>(.*)</title>"
StringIndex=4
StringIndex2=1
Substitute=#Sub#
[MeasureItem2Link]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<link>(.*)</link>"
StringIndex=4
StringIndex2=1
[MeasureItem3Title]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<title>(.*)</title>"
StringIndex=5
StringIndex2=1
Substitute=#Sub#
[MeasureItem3Link]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<link>(.*)</link>"
StringIndex=5
StringIndex2=1
[MeterMainTitle]
Meter=String
MeasureName=MeasureMainTitle
X=0
Y=0
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringStyle=Bold
Antialias=1
LeftMouseUpAction=["[MeasureMainLink]"]
[MeterItem1Title]
Meter=String
MeasureName=MeasureItem1Title
X=0
Y=5R
W=300
H=35
ClipString=1
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
Antialias=1
LeftMouseUpAction=["[MeasureItem1Link]"]
[MeterItem2Title]
Meter=String
MeasureName=MeasureItem2Title
X=0
Y=5R
W=300
H=35
ClipString=1
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
Antialias=1
LeftMouseUpAction=["[MeasureItem2Link]"]
[MeterItem3Title]
Meter=String
MeasureName=MeasureItem3Title
X=0
Y=5R
W=300
H=35
ClipString=1
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
Antialias=1
LeftMouseUpAction=["[MeasureItem3Link]"]
First, we set a variable that simply gets everything in between <item> and </item> from the site.
Code: Select all
[Variables]
Item=.*<item>(.*)</item>
Code: Select all
[MeasureSite]
Measure=Plugin
Plugin=WebParser
Url=http://feeds.gawker.com/lifehacker/full
RegExp="(?siU)<channel>.*<image>.*<title>(.*)</title>.*<link>(.*)</link>#Item##Item##Item#"
Now let's skip the measures for the main title and link, they are done the normal way. Let's move down to this measure:
Code: Select all
[MeasureItem1Title]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<title>(.*)</title>"
StringIndex=3
StringIndex2=1
Substitute=#Sub#
Remember, the way StringIndex2 works is that IF a WebParser measure is using an earlier WebParser measure as the Url= AND the measure has a RegExp= on it, then the RegExp= is applied to the data in StringIndex, and the result is returned in StringIndex2.
The "value" of the measure, when used for instance in a MeasureName= option in a meter, is what is returned in StringIndex2.
We can repeat this process to get the link of the first item:
Code: Select all
[MeasureItem1Link]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<link>(.*)</link>"
StringIndex=3
StringIndex2=1
It might be obvious by now, but when we want to carry on with the second <item> from the feed, we use:
Code: Select all
[MeasureItem2Title]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
RegExp="(?siU)<title>(.*)</title>"
StringIndex=4
StringIndex2=1
Substitute=#Sub#
Play with this a bit, and you might find that it can save a lot of extra parsing and creating huge RegExp= options to parse absolutely everything out of a site all at once up front. Get the main site in big chunks, then deal with the chunks as if they were sites in and of themselves.
Hint: This can be a nice way to get around the limit of 99 StringIndex numbers on any single WebParser measure...