Substitutions ae done in a progressive order; the first substitution is performed and passed on to the second substitution, and so on... that is why only your
last substitution gave the desired result.
What you need to do in this case is to use
RegExpSubstitute=1 and restrict the substations to exactly the one single digit using line beginning
^ and line end
$ symbols as Yincognito suggested. This will prevent the second and third substitutions from substituting all matching values in the previous substitution string.
-=-
Where substitution can go wrong... If you do not use RegExpSubstition=1 and restrict the match to a set of unique characters, this is what happens:
All images are located at:
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png
Your normal substitution:
Substitute="0":"#@#Play.png","1":"#@#Pause.png","2":"#@#Play.png"
When the STATE is zero, the "0" is replaced with a resulting string of:
"
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png"
So far so good, but...That string value is sent to the next substitution, where every "1" is replaced with
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png" with a resulting string of:
"
\\\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png92.\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png68.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png"
Things are getting messy, but wait... That string is passed to the last substitution, where every "2" is replaced with
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png with a resulting string of:
"
\\\\19\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png9\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png.\\19\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png68.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png"
-=-
Okay, that's not what you want as results, so how do you make it work?
The correct way to substitute for defined characters (as suggested by Yincognito):
Code: Select all
[MeasureStateButton]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#Player#
PlayerType=STATE
RegExpSubstitution=1
Substitute="^0$":"#@#Play.png","^1$":"#@#Pause.png","^2$":"#@#Play.png"
When the STATE is "0" the
entire substitution result is: "
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png"
No other substitutions are done because the "1", and "2" values are NOT individual characters, they are combined with other characters.
When the STATE is "1" the
entire substitution result is: "
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Pause.png"
No other substitutions are done because the "2" values are NOT individual characters, they are combined with other characters.
When the STATE is "2" the
entire substitution result is: "
\\192.168.XXX.XXX\XXXData\Documents\Rainmeter\Skins\Mond\@Resources\Play.png"
Hope this help explain a bit better...
Remember that normal Substitutions are done in the order they appear from first to last, with the previous substitutions used for the next substitution. RegExpSubstitution=1 allows you to define specific string values and control
what is substituted and
when.