It is currently April 19th, 2024, 4:15 am

Forgotten so much. Back to the simple things.

Get help with creating, editing & fixing problems with skins
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Forgotten so much. Back to the simple things.

Post by Codger »

I stepped away for a few weeks and given my retention I've forgotten about 75% of what I learned. Here is once example of a problem I'm having.

I have a measure: [MeasurePostalCode] which returns as the string value the zip code of the IP you are on. This is working flawlessly as seen in both a meter and in the skin variable log.

I want to change the color of all text in the skin if the zip code is one of two codes. I have
FontColor=[SetWarningColor]
in several spots.

Code: Select all

[SetWarningColor]
Measure=String
String=[MeasurePostalCode]
IfMatch=02346|02347
IfMatchAction=[!SetOption SetWarningColor String #PureRed#]
IfNotMatchAction=[!SetOption SetWarningColor String #PureWhite#]
IfMatchMode=1
DynamicVariables=1
;UpdateDivider=-1
No matter what the zipcode the measure returns 255,255,255
If the zipcode is one of those two and I comment out the IfNot... it returns 255.0.0
Somehow both If and IfNot are being triggered.
What am I doing wrong?
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Forgotten so much. Back to the simple things.

Post by mak_kawa »

I think...at the first update cycle, the measure gets String value from [MeasurePostalCode] and evaluates it to change String option itself to, for example, "255,255,255". Then the String option of the measure is always "String=255,255,255", and can not recieve [MeasurePostalCode] value anymore.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Forgotten so much. Back to the simple things.

Post by jsmorley »

mak_kawa wrote:I think...at the first update cycle, the measure gets String value from [MeasurePostalCode] and evaluates it to change String option itself to, for example, "255,255,255". Then the String option of the measure is always "String=255,255,255", and can not recieve [MeasurePostalCode] value anymore.
Correct, mak_kawa. I don't really get the logic here.

Codger , sure you don't mean something like:

Code: Select all

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

[Variables]
PureRed=255,0,0,255
PureWhite=255,255,255,255

[MeasurePostalCode]
Measure=String
String=02347

[SetWarningColor]
Measure=String
String=[MeasurePostalCode]
IfMatch=02346|02347
IfMatchAction=[!SetOptionGroup MyMeters FontColor #PureRed#]
IfNotMatchAction=[!SetOptionGroup MyMeters FontColor #PureWhite#]
;IfMatchMode=1
DynamicVariables=1
;UpdateDivider=-1

[MeterOne]
Meter=String
Group=MyMeters
MeasureName=MeasurePostalCode
FontSize=11
FontWeight=400
FontColor=#PureWhite#
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

[MeterTwo]
Meter=String
Group=MyMeters
MeasureName=MeasurePostalCode
Y=5R
FontSize=11
FontWeight=400
FontColor=#PureWhite#
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Hello World
1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Forgotten so much. Back to the simple things.

Post by jsmorley »

P.S. Don't overuse IfMatchMode=1 on stuff.

The way IfMatch and IfCondition work is that they only fire the "true" action one time when the result of the "test" changes from false to true. However, in this case once the test is "true", and you set the FontColor, you don't want to change it again until and unless the test becomes "false". There is just no need to hammer a !SetOption on every measure update, just to set the FontColor from "red" to "red".

There is a place for IfMatchMode (and IfConditionMode), but it is when you want the action to set something that is going to be "dynamic" on each skin update.

So for instance:

Code: Select all

[MeasureSeconds]
Measure=Time
Format=%#S

[MeasureTest]
Measure=Calc
Formula=MeasureSeconds
IfCondition=MeasureTest <= 30
IfTrueAction=[!SetOption SomeMeter FontColor "255,255,255,255"][!SetOption SomeMeter Text "The current seconds of [MeasureSeconds] is less than or equal to 30][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption SomeMeter FontColor "255,0,0,255"][!SetOption SomeMeter Text "The current seconds of [MeasureSeconds] is greater than 30][!UpdateMeter *][!Redraw]
IfConditionMode=1
While this is a nonsense example, the point is that you want the dynamic and current value of [MeasureSeconds] to be set on the Text option of the meter SomeMeter on every update of the measure. You don't want to only set it once when the test is "true" or "false", but each time, so the current value is used.

The times you will need IfMatchMode or IfCondition mode are rare... Basically it is saying "fire the action EVERY TIME the test is "true", not just when it BECOMES "true"."

Keep in mind, this:

Code: Select all

[MeasureCalc]
Measure=Calc
Formula=1
IfCondition=MeasureCalc=1
IfTrueAction=[!Update]
IfConditionMode=1
Is a runaway freight train endless loop that will use all available CPU resources until your PC just bursts into flames.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Forgotten so much. Back to the simple things.

Post by Codger »

I'm still missing the original sin. Why does it lock in on the first run and not update when updated?

Let's say that for the sake of future extrapolation I really wanted to construct this in a way that [setwarningcolor] could be used as a variable with a value of one of the two colors based on the criteria in the OP. How would I construct that? I've tried countless different routes and there is always some rule that blocks the final pieces coming together or it functioning.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Forgotten so much. Back to the simple things.

Post by jsmorley »

Codger wrote:I'm still missing the original sin. Why does it lock in on the first run and not update when updated?

Let's say that for the sake of future extrapolation I really wanted to construct this in a way that [setwarningcolor] could be used as a variable with a value of one of the two colors based on the criteria in the OP. How would I construct that? I've tried countless different routes and there is always some rule that blocks the final pieces coming together or it functioning.
Well, let's explore your code...

Code: Select all

[SetWarningColor]
Measure=String
String=[MeasurePostalCode]
IfMatch=02346|02347
IfMatchAction=[!SetOption SetWarningColor String #PureRed#]
IfNotMatchAction=[!SetOption SetWarningColor String #PureWhite#]
IfMatchMode=1
DynamicVariables=1
;UpdateDivider=-1
Lets' say that on the first skin update the value of [MeasurePostalCode] is 02347. What happens?

The IfMatchAction is "true"

It changes the String option on the measure [SetWarningColor] from being the current value of [MeasurePostalCode] to being a static "255,0,0,255" or whatever the value of #PureRed# is. So now it is:

Code: Select all

[SetWarningColor]
Measure=String
String=255,0,0,255
IfMatch=02346|02347
IfMatchAction=[!SetOption SetWarningColor String #PureRed#]
IfNotMatchAction=[!SetOption SetWarningColor String #PureWhite#]
IfMatchMode=1
DynamicVariables=1
;UpdateDivider=-1
On the very next update the IfMatch is now certain to be "false", as it certainly can't be 02346 OR 02347, it's hard coded to "255,0,0,255"

So the IfMatchAction is "false"

It changes the the String option on the measure [SetWarningColor] from being a static "255,0,0,255" to being a static "255,255,255,255" or whatever the value of #PureWhite# is. So now it is:

Code: Select all

[SetWarningColor]
Measure=String
String=255,255,255,255
IfMatch=02346|02347
IfMatchAction=[!SetOption SetWarningColor String #PureRed#]
IfNotMatchAction=[!SetOption SetWarningColor String #PureWhite#]
IfMatchMode=1
DynamicVariables=1
;UpdateDivider=-1
This will ALWAYS and forever be "false" and it just stays white until you refresh the skin. At that point it will start over, red once, white forever...

It no longer cares what the value of [MeasurePostalCode] is, why would it?

See my earlier post with an example of what I think you intend, and how to get there.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Forgotten so much. Back to the simple things.

Post by Codger »

Thank you that makes perfect sense now. Very nicely explained.

However that still does not take me where I want to go. The earlier code you gave would work fine in this one case but would not allow me to extrapolate to future needs.

In simplest terms I essentially need to know how to do a conditional calc but with characters not numbers resultimg in being able to read the answer as the routines variable reference (x=[])

I originally thought
Measure=string
MeasureName=[MeasurePostalCode]

but this did not work either.
I'm guessing String is not the right measure for this but looking at the choices I'm not seeing a better contender.

Hopelessly confused.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."