It is currently March 28th, 2024, 8:41 am

Replace text

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Replace text

Post by sl23 »

Ok, I give up! I'm trying to detect if WiFi is connected or not and show the relevant icon, but it refuses to work.
I've tried many many variations with and without the Substitute, please can someone put me out of my misery :-(

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
;IfAboveValue=-1
;IfAboveAction=[!SetOption WiFiIcon Text "[\xEB5E]"]
;IfBelowValue=0
;IfBelowAction=[!SetOption WiFiIcon Text "[\xE701]"]
;IfCondition=mSSID = -1
;IfTrueAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
;IfFalseAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
Substitute="-1":"No WiFi"
IfMatch=mSSID = "No WiFi"
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
I've checked both the manual and the 'About/Skins' window to see what the 'String' is and still I just don't understand what I'm doing wrong!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Replace text

Post by jsmorley »

Try this:

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
IfMatch=-1
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
IfMatch does not have a "test what?" parameter like IfCondition does. It is based on the string value of the measure it is on.

Also, "quotes" are not required around the regular expression you are testing with.

So it's not IfMatch=mSSID="-1", but rather IfMatch=-1
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Replace text

Post by sl23 »

Thank you! Thank you! Thank you! :D
And it works with the Substitute too...

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
Substitute="-1":"No WiFi"
IfMatch="No WiFi"
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Replace text

Post by jsmorley »

sl23 wrote: August 19th, 2021, 10:28 pm Thank you! Thank you! Thank you! :D
And it works with the Substitute too...

Code: Select all

[mSSID]
Measure=Plugin
Plugin=WiFiStatus
WiFiInfoType=SSID
Substitute="-1":"No WiFi"
IfMatch="No WiFi"
IfMatchAction=[!SetOption WiFiIcon Text "[\xEB5E]"] [!UpdateMeter *] [!Redraw]
IfNotMatchAction=[!SetOption WiFiIcon Text "[\xE701]"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
Ok, not sure I see any point for the Substitute, but maybe you are using the string value somewhere else. Also, don't enclose the regular expression in "quotes". They are not needed, and are just thrown away by Rainmeter.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Replace text

Post by sl23 »

Ah, yes, the substitute is used in another meter.
Regarding quotes, it's never clear when I should or shouldn't use them. Mostly things are copied from old skins I have and new features added as I learn, but things like this get copied too.

Thanks for your help. :thumbup:
Last edited by sl23 on August 20th, 2021, 6:35 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Replace text

Post by jsmorley »

sl23 wrote: August 19th, 2021, 10:46 pm Ah, yes, the substitute is used in another meter.
Regarding quotes, it's never clear when I should or shouldn't use them. Mmptjw things are copied from old skins I have and new features added as I learn, but things like this get copied too.

Thanks for your help. :thumbup:
Glad to help. In most cases, quotes where they are not needed is not a problem. But in short the rule is:

Never use quotes at the beginning and end of any option value. They are never needed, and always thrown away. Substitute is the single special case.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Replace text

Post by Yincognito »

jsmorley wrote: August 19th, 2021, 11:12 pmSubstitute is the single special case.
And bangs, if I'm not mistaken (when you intend that value to be a string and to be sure spaces are handled properly). :???:

P.S. Just re-read you post, you were talking about option values, where Substitute is indeed the only case. But then, I guess it doesn't hurt to expand the details to the whole Rainmeter system though, at least for informative purposes.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Replace text

Post by jsmorley »

Yincognito wrote: August 20th, 2021, 1:03 pm And bangs, if I'm not mistaken (when you intend that value to be a string and to be sure spaces are handled properly). :???:

P.S. Just re-read you post, you were talking about option values, where Substitute is indeed the only case. But then, I guess it doesn't hurt to expand the details to the whole Rainmeter system though, at least for informative purposes.
https://forum.rainmeter.net/viewtopic.php?f=118&t=27870
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Replace text

Post by Yincognito »

Indeed. :thumbup:
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Replace text

Post by sl23 »

Excellent, thanks for the info and the link.
  Need to revise a bit on that :D  
Post Reply