[solved] Using IfMatch & IfEqualAction to amend NET_MASK output

Help with creating, editing & fixing problems with skins
User avatar

[solved] Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 3:54 pm
Mor3bane
   [426 posts]

Hello everyjello

I will post this cod - it is incomplete and likely wrong - I stopped when I got to the IfEqualAction line since I am not sure how to structure the amendment to the NET_MASK output.

Just to elaborate I am referring to this table:


I want to compare the NET_MASK output to this table in reference to the IP address classes. Ao if the output of NET_MASK is 255.255.255.0 it would be amended with the letter C and over the whole table options for class A, B, and C. Dand E are unlikely to ever be used by me.

Here is my incomplete code:

Code: Select all

[MeasureMaskCalc]
Measure=Calc
Formula=[MeasureNetMask]
IfMatch=255.255.255.0
IfEqualAction=[!SetOption CentreTextU InlineSetting (*/) "(Config)"]

[MeasureNetMask]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NET_MASK
UpdateDivider=100

[CentreTextU]
Meter=String
MeasureName=MeasureNetMask
X=10
Y=10
StringAlign=Center
Text=%1
InlineSetting=Case | Upper
FontColor=190,190,190,255
StringCase=Proper
FontFace=CourierNew
FontSize=25


Thanks for any and all assistance :D
Last edited by Mor3bane on June 15th, 2018, 4:21 am, edited 1 time in total.
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 7:14 pm
balala
Rainmeter Sage   [6271 posts]

A Calc measure must be entirely numeric. Since the value returned by the [MeasureNetMask] is an IP address, this is a string, even if it is composed by numbers. So, you can't use it into a Calc measure.
I'd replace the Calc measure with a String measure:

Code: Select all

[MeasureMaskCalc]
Measure=String
String=[MeasureNetMask]
IfMatch=255.255.255.0
IfEqualAction=[!SetOption CentreTextU InlineSetting (*/) "(Config)"]
DynamicVariables=1

Note that this measure as it is written, requires a DynamicVariables=1 option (added).
In the [MeasureMaskCalc] measure, you have an IfMatch option, but there is no IfMatchAction or IfNotMatchAction. There is instead an IfEqualAction option. These two options have nothing to do each other. Probably instead of the IfEqualAction, you should have to use an IfMatchAction.
Beside this, I also didn't understand what the !SetOption bang should have to do. The posted code has a [CentreTextU] meter, but the !SetOption will set the appropriate option onto another [CentreTextU] meter, placed into another not specified config - "(Config)".
So, I'm not sure at all what would be the essence of this bang.
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 9:13 pm
Mor3bane
   [426 posts]

Thanks balala :D

That is really helpful in moving forward :17good

I hope you dont mind some pseudocode?

IfMatchAction=[!SetOption CentreTextU... for "Value" Inlinesetting would be used to - I was hoping to use regexp(?) to capture the output then in the regexp the appropriate letter would be amended - with a space after the IP address... I would use three different meter sets for each amending letter and ip address. e.g. A or B or C.

Did that explain it the final output for example would be for C (the most common BTW) would be:
255.255.255.0 C

Without what I am trying to do the correct output for what I know is class C:
255.255.255.0
Does that illustrate my intention?

The purpose would be to monitor my IP as my VPN changes countries, for example.

:welcome:
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 9:42 pm
FreeRaider
   [700 posts]

Sorry but I do not understand.

Would you like
1) take the net.mask from the measure [MeasureNetMask]
2) add a letter to the IP with reference to the image (for example if IP is 255.255.255.0 then C is added)
3) show the IP plus the letter via the meter [CentreTextU] ????
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 10:01 pm
Mor3bane
   [426 posts]

FreeRaider wrote:Sorry but I do not understand.

Would you like
1) take the net.mask from the measure [MeasureNetMask]
2) add a letter to the IP with reference to the image (for example if IP is 255.255.255.0 then C is added)
3) show the IP plus the letter via the meter [CentreTextU] ????


Most exactly.

My interpretation of this is to gauge which VPN IPs have the most traffic e.g. for MMO gaming/torrenting etc.
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 14th, 2018, 10:10 pm
FreeRaider
   [700 posts]

My try

Code: Select all

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

[MeasureNetMask]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NET_MASK
UpdateDivider=1000
IfMatch=^255\..*
IfMatchAction=[!SetOption CentreTextU Text "[MeasureNetMask] A"]
IfMatch2=^255\.255\..*
IfMatchAction2=[!SetOption CentreTextU Text "[MeasureNetMask] B"]
IfMatch3=^255\.255\.255\..*
IfMatchAction3=[!SetOption CentreTextU Text "[MeasureNetMask] C"]
IfMatchMode=1

[CentreTextU]
Meter=String
X=10
Y=10
StringAlign=Left
InlineSetting=Case | Upper
FontColor=190,190,190,255
StringCase=Proper
FontFace=CourierNew
FontSize=25
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 15th, 2018, 4:18 am
Mor3bane
   [426 posts]

FreeRaider wrote:My try

Code: Select all

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

[MeasureNetMask]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NET_MASK
UpdateDivider=1000
IfMatch=^255\..*
IfMatchAction=[!SetOption CentreTextU Text "[MeasureNetMask] A"]
IfMatch2=^255\.255\..*
IfMatchAction2=[!SetOption CentreTextU Text "[MeasureNetMask] B"]
IfMatch3=^255\.255\.255\..*
IfMatchAction3=[!SetOption CentreTextU Text "[MeasureNetMask] C"]
IfMatchMode=1

[CentreTextU]
Meter=String
X=10
Y=10
StringAlign=Left
InlineSetting=Case | Upper
FontColor=190,190,190,255
StringCase=Proper
FontFace=CourierNew
FontSize=25


Beyond a shadow of a doubt working exactly to desired outcome!

THANKS FreeRaider :thumbup: :welcome:
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 15th, 2018, 12:23 pm
balala
Rainmeter Sage   [6271 posts]

FreeRaider wrote:My try

I'd modify something in this code: probably there is no need at all to use the IfMatchMode=1 option on the [MeasureNetMask] measure, because the appropriate option doesn't have to be set on each update cycle. Probably an UpdateDivider=-1 would be even better, because the IP doesn't change, so once a value set, it doesn't have to be updated.
User avatar

Re: Using IfMatch & IfEqualAction to amend NET_MASK output

June 15th, 2018, 2:02 pm
FreeRaider
   [700 posts]

Mor3bane wrote:Beyond a shadow of a doubt working exactly to desired outcome!

THANKS FreeRaider :thumbup: :welcome:


Glad to help.


balala wrote:I'd modify something in this code: probably there is no need at all to use the IfMatchMode=1 option on the [MeasureNetMask] measure, because the appropriate option doesn't have to be set on each update cycle. Probably an UpdateDivider=-1 would be even better, because the IP doesn't change, so once a value set, it doesn't have to be updated.


I do not know if the OP has a dynamic IP.

Return to “Help: Rainmeter Skins”



Who is online

Users browsing this forum: dragan, xenium and 5 guests