It is currently April 20th, 2024, 2:20 pm

How can I execute a OnChangeAction only when certain criteria are met?

Get help with creating, editing & fixing problems with skins
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

How can I execute a OnChangeAction only when certain criteria are met?

Post by kyriakos876 »

Hello, I have this measure that executes a command after the value of this measure has changed:

Code: Select all

[MeasureTitle]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Title
Substitute="":"N/A"
OnChangeAction=[!Delay 2300][!CommandMeasure MeasureAnimation "Execute 1"]
DynamicVariables=1
I want the OnChangeAction to not be executed if the value of that Measure becomes "N/A". How would I do that?

NOTE: I tried IfMatch but it works only once.

-Thanks in advance.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How can I execute a OnChangeAction only when certain criteria are met?

Post by balala »

kyriakos876 wrote:I want the OnChangeAction to not be executed if the value of that Measure becomes "N/A". How would I do that?
Try this:

Code: Select all

[MeasureTitle]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Title
Substitute="":"N/A"
IfMatch=N/A
IfMatchAction=[!SetOption MeasureTitleS OnChangeAction """[!Delay 2300][!CommandMeasure MeasureAnimation "Execute 1"]"""][!UpdateMeasure "MeasureTitleS"]
IfNotMatchAction=[!SetOption MeasureTitleS OnChangeAction "[]"][!UpdateMeasure "MeasureTitleS"]
DynamicVariables=1

[MeasureTitleS]
Measure=String
String=[MeasureTitle]
DynamicVariables=1
As you can see, depending on the value returned by the [MeasureTitle] measure, the OnChangeAction option is set or removed from the second measure [MeasureTitleS].
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: How can I execute a OnChangeAction only when certain criteria are met?

Post by kyriakos876 »

balala wrote:Try this:

Code: Select all

[MeasureTitle]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Title
Substitute="":"N/A"
IfMatch=N/A
IfMatchAction=[!SetOption MeasureTitleS OnChangeAction """[!Delay 2300][!CommandMeasure MeasureAnimation "Execute 1"]"""][!UpdateMeasure "MeasureTitleS"]
IfNotMatchAction=[!SetOption MeasureTitleS OnChangeAction "[]"][!UpdateMeasure "MeasureTitleS"]
DynamicVariables=1

[MeasureTitleS]
Measure=String
String=[MeasureTitle]
DynamicVariables=1
As you can see, depending on the value returned by the [MeasureTitle] measure, the OnChangeAction option is set or removed from the second measure [MeasureTitleS].
This works but I wanted it to work the opposite way, so now when it says "N/A" it's not activated, which is what I was going for. I just swapped IfMatchAction with IfNotMatchAction.

Thanks for the help. I don't know why but I can't seem to find simple solutions to simple problems... I only find the weirdest solutions for easy problems but simple ones for the more complex problems....
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How can I execute a OnChangeAction only when certain criteria are met?

Post by balala »

kyriakos876 wrote:This works but I wanted it to work the opposite way, so now when it says "N/A" it's not activated, which is what I was going for. I just swapped IfMatchAction with IfNotMatchAction.
Sorry I've misunderstood. Swapping those options is indeed the solution.
kyriakos876 wrote:Thanks for the help. I don't know why but I can't seem to find simple solutions to simple problems... I only find the weirdest solutions for easy problems but simple ones for the more complex problems....
Don't worry, this will come if you keep working, as you're accumulating more and more experience.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: How can I execute a OnChangeAction only when certain criteria are met?

Post by kyriakos876 »

balala wrote:Sorry I've misunderstood. Swapping those options is indeed the solution.
Happens. ^_^
balala wrote:Don't worry, this will come if you keep working, as you're accumulating more and more experience.
Can't argue that!