It is currently February 22nd, 2020, 7:45 am

Condition/action to alter a Measure's output?

Help with creating, editing & fixing problems with skins
User avatar
poisonborz
Posts: 10
Joined: November 25th, 2009, 6:52 pm

Condition/action to alter a Measure's output?

Post by poisonborz »

I have a Measure (MeasurePCCode), that gets its value from a Webparser regexp.
However, I want to modify this in a way that if the computer's name matches with a string, a fixed value should be the result there, not the regexp value. Is it possible to alter a measure's output in this way?
[MeasurePCName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=COMPUTER_NAME
IfMatch=PC1
IfMatchAction=[!SetVariable PCCodeVar 1]
IfMatch2=PC2
IfMatch2=[!SetVariable PCCodeVar 2]

[MeasurePCCode]
Measure=Plugin
Plugin=WebParser
DynamicVariables=1
URL=[PCCode]
StringIndex=1
Or reversed, is it possible to conditionally change the input in another Measure?
Like URL=https://example.com/search/?q=[&PCCodeVar || MeasurePCCode]
User avatar
jsmorley
Developer
Posts: 20258
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Condition/action to alter a Measure's output?

Post by jsmorley »

I may not understand exactly, but something like this?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasurePCName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=COMPUTER_NAME
IfMatch=(?i)TOwER
IfMatchAction=[!SetOption MeasureString String "[*MeasurePCName*]"]
IfNotMatchAction=[!SetOption MeasureString String "[*MeasurePCCode*]"]

[PCCode]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<item>(.*)</item>

[MeasurePCCode]
Measure=Plugin
Plugin=WebParser
URL=[PCCode]
StringIndex=1
DynamicVariables=1

[MeasureString]
Measure=String
String=[MeasurePCCode]
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureString
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
https://docs.rainmeter.net/manual/variables/#Escape

Test.html:

Code: Select all

<item>BobSmith</item>
User avatar
poisonborz
Posts: 10
Joined: November 25th, 2009, 6:52 pm

Re: Condition/action to alter a Measure's output?

Post by poisonborz »

Yes, thank you! SetOption was what I was looking for, I previously tried to solve this with variables.
User avatar
balala
Rainmeter Sage
Posts: 9741
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Condition/action to alter a Measure's output?

Post by balala »

poisonborz wrote:
January 13th, 2020, 6:04 pm
Yes, thank you! SetOption was what I was looking for, I previously tried to solve this with variables.
Although possible, I doubt it worth:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
MyVariable=0

[MeasurePCName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=COMPUTER_NAME
IfMatch=(?i)TOwER
IfMatchAction=[!SetVariable MyVariable "1"][!UpdateMeasure "MeasureComputerName"]
IfNotMatchAction=[!SetVariable MyVariable "0"][!UpdateMeasure "MeasureComputerName"]

[MeasureComputerName]
Measure=Calc
Formula=#MyVariable#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!SetOption MeasureString String "[*MeasurePCName*]"]
IfFalseAction=[!SetOption MeasureString String "[*MeasurePCCode*]"]

[PCCode]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<item>(.*)</item>

[MeasurePCCode]
Measure=Plugin
Plugin=WebParser
URL=[PCCode]
StringIndex=1
DynamicVariables=1

[MeasureString]
Measure=String
String=[MeasurePCCode]
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureString
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1