It is currently April 26th, 2024, 8:54 am

Trouble with []. Can't keep it straight

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

Trouble with []. Can't keep it straight

Post by Codger »

Okay I've stripped this code down to the smallest functional part.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
Blur=1
MiddleMouseDownAction=!RainmeterDeactivateConfig

[Variables]

BackHeight=216
BackPadding=15
BarWidth=330
BackColor=25,25,25,200
BackBorder=255,255,0,50

FontFace=Microsoft Sans Serif
FontColor=#PureWhite#,240
FontSize=10

OfflineColor=255,0,0,255
OnlineStatusLast=Unknown

[Background]
Meter=Shape
Shape=Rectangle 0,0,(#BarWidth# + (#BackPadding#*2) + 1),#BackHeight# | Fill Color #BackColor# | StrokeWidth 1 | Stroke Color #BackBorder#
UpdateDivider=-1


[DetectInternet]
; Offline
; Online
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
Substitute="-1":"Offline", "1":"Online"
UpdateDivider=-1

[MeterInternetStatus]
Meter=String
MeasureName=DetectInternet
X=(#BarWidth#+#BackPadding#)
Y=15
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
InlineSetting=Color | #OfflineColor#
InlinePattern=Offline
Text="Status: %1"
UpdateDivider=-1


;
;
; Update Everything on Switch in Online/Offline Status
;    This Section Should Remain Last

[MeasureConnectionChangeCheck]
Measure=String
String=[DetectInternet]
IfMatch=#OnlineStatusLast#
IfNotMatchAction=[!SetVariable OnlineStatusLast [DetectInternet]][!UpdateMeter "MeterInternetStatus"]
IfMatchMode=1
!UpdateMeasure "DetectInternet"
DynamicVariables=1
UpdateDivider=1
Never mind that it is rather inside out. As the complexity grows the madness in the method becomes more apparent.
But the problem remains that it does not work.
When run it works fine. Detects and displays whether it is online or not.
But change whether you are online or not and the skin does not update (unless refreshed)

The routines [DetectInternet] and [MeterInternetStatus] run only when updated by design.

I'd assume that the the first run through was pulling all the work and that [MeasureConnectionChangeCheck] wasn't running but: OnlineStatusLast gets the right value so the IfNotMatchAction is triggering.
That would point the finger at the following bang which may or may not be working right.
BUT [DetectInternet] is not registering the change so the !UpdateMeasure "DetectInternet" line is not working (?)
I'd rather avoid a heavy handed like a redraw (which still wouldn't update [DetectInternet] anyway) or refresh bang.

I assume I'm using or not a [] where I should/shouldn't but damned if I can find it.
Help please.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with []. Can't keep it straight

Post by balala »

Codger wrote:When run it works fine. Detects and displays whether it is online or not.
But change whether you are online or not and the skin does not update (unless refreshed)

The routines [DetectInternet] and [MeterInternetStatus] run only when updated by design.
Remove the UpdateDivider=-1 option of the [DetectInternet] measure and [MeterInternetStatus] meter. This options make the measure and meter to never be updated, that's why the skin doesn't detect the change.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Trouble with []. Can't keep it straight

Post by Codger »

But I want them to not run unless expressly called. Which they should be (to my limited understanding) by the final routine. I realize it looks odd as the final routine is updating every second anyway. But as more routines get hooked into updating on when online/offline changes it begins to make sense as a template.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with []. Can't keep it straight

Post by balala »

Codger wrote:But I want them to not run unless expressly called. Which they should be (to my limited understanding) by the final routine. I realize it looks odd as the final routine is updating every second anyway. But as more routines get hooked into updating on when online/offline changes it begins to make sense as a template.
If by "final routine" you mean the [MeasureConnectionChangeCheck] measure and if you leave the two UpdateDivider=-1 options, the described behavior is not a strange thing: the [DetectInternet] measure is never updated, but the [MeasureConnectionChangeCheck] measure has the same value as [DetectInternet]. Even if on the [MeasureConnectionChangeCheck] measure you've set the UpdateDivider=1, this measure never changes, because its "master" measure ([DetectInternet]) is never updated. If [MeasureConnectionChangeCheck] never changes, its IfNotMatchAction option is never executed (even if you set up the IfMatchMode=1 option).

And one more: remove or move the "orphan" !UpdateMeasure "DetectInternet" option on the [MeasureConnectionChangeCheck] measure (third from the end), to the IfNotMatchAction option, where I think it belongs.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Trouble with []. Can't keep it straight

Post by Codger »

balala wrote:If by "final routine" you mean the [MeasureConnectionChangeCheck] measure and if you leave the two UpdateDivider=-1 options, the described behavior is not a strange thing: the [DetectInternet] measure is never updated, but the [MeasureConnectionChangeCheck] measure has the same value as [DetectInternet]. Even if on the [MeasureConnectionChangeCheck] measure you've set the UpdateDivider=1, this measure never changes, because its "master" measure ([DetectInternet]) is never updated. If [MeasureConnectionChangeCheck] never changes, its IfNotMatchAction option is never executed (even if you set up the IfMatchMode=1 option).

And one more: remove or move the "orphan" !UpdateMeasure "DetectInternet" option on the [MeasureConnectionChangeCheck] measure (third from the end), to the IfNotMatchAction option, where I think it belongs.
Perhaps this is where my confusion lies.

You say [DetectInternet] never gets updated and then call the !UpdateMeasure "DetectInternet" orphaned. But should not that !UpdateMeasure "DetectInternet" update [DetectInternet] as the UpdateMeasure bang is supposed to override any Updatedivider commands (or so the manual says) thus updating the measure and the following bang displaying the updated value.

And we know IfNotMatchAction does run because !SetVariable OnlineStatusLast [DetectInternet] runs (the variable interface shows OnlineStatusLast with a value other than initialized.) So why does the UpdateMeasure bang not update the measure?

From the manual:
!UpdateMeasure Parameters: Measure, Config

Overrides the setting of the Update option in [Rainmeter] or [b]any UpdateDivider on the measure, and immediately updates the measure[/b].
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Trouble with []. Can't keep it straight

Post by FreeRaider »

Codger wrote:But should not that !UpdateMeasure "DetectInternet" update [DetectInternet] as the UpdateMeasure bang is supposed to override any Updatedivider commands (or so the manual says) thus updating the measure and the following bang displaying the updated value.
From the manual:

Bangs are action commands that control various aspects of skins and Rainmeter. They are executed when used with action options in the skin.

Action Options
Options in a skin which cause Rainmeter to take some action. Actions may be triggered by user input such as mouse actions or changing values and system events within the skin, such as IfActions or OnUpdateAction.

See also
MouseActions
OnUpdateAction
OnChangeAction
IfActions
IfConditions
IfMatchActions
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Trouble with []. Can't keep it straight

Post by Codger »

Ah ha! I knew I was misunderstanding something.

So can I do something along the lines of ifmatch 0=0...?
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Trouble with []. Can't keep it straight

Post by FreeRaider »

IfMatch works in this way:

if you match something then do this action or do not this action

For example

Code: Select all

[MeasureDate]
Measure=Time
Format=%A, %B %#d, %Y
IfMatch=Saturday|Sunday
IfMatchAction=[!SetOption MeterDayofWeek Text "The date is [MeasureDate]#CRLF#It's a weekend"]
IfNotMatchAction=[!SetOption MeterDayofWeek Text "The date is [MeasureDate]#CRLF#It's a weekday"]
IfMatchMode=1

[MeterDayofWeek]
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
IfConditions works in this way

if a measure is < or > or = or <> (not egual) to something then if it is true do this action else do this second action.

For example

Code: Select all

[MeasureCPU]
Measure=CPU
IfCondition=MeasureCPU < 10
IfTrueAction=[!SetOption MeterCPU Text "CPU usage is less than 10 percent"]
IfCondition2=(MeasureCPU >= 10) && (MeasureCPU <= 90)
IfTrueAction2=[!SetOption MeterCPU Text "CPU usage is between 10 and 90 percent"]
IfCondition3=MeasureCPU > 90
IfTrueAction3=[!SetOption MeterCPU Text "CPU usage is more than 90 percent!"]
OnUpdateAction=[!UpdateMeter MeterCPU][!Redraw]
[MeterCPU]
Meter=String
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trouble with []. Can't keep it straight

Post by jsmorley »

One difference to keep in mind, aside from the obvious that IfMatch is about "matching strings" and IfCondition is about "testing numeric values and formulas", is that IfMatch and IfActions both work on the current value of the measure they are used in. IfConditions is more free-form, in that it supports and requires that the test define both the value you are testing, and the test you are applying to it. So it can be used on any measure, as it is unrelated in a sense to the measure it is on.

If you look at them:

IfMatch=SomeRegularExpression

IfCondition=SomeValue=SomeOtherValue

IfMatch will and must use the value and only the string value of the measure it is on as the string to compare to some regular expression.

IfCondition has the additional definition of "SomeValue", which can be any measure, number or formula.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Trouble with []. Can't keep it straight

Post by Codger »

Thank you. I would have leapt in without asking but I was eating dinner (with the sunrise thanks to switched around sleeping) and it was something that required one and half hands. :D Plus I was half hoping you would respond with some more direct way.

But it looks like I just need to craft a condition that is always true or not and then use my bang. I'm heading back to the real computer comfortable with the knowledge that between your pointers and the manual and my misunderstanding pointing out I can get outer shell done and start working my way back in.

Thank you never much. I love this community. Tomorrow I should be acclimatized and more able so if I have to post question I promise they won't be so basic nor will I give in so easily.

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