It is currently March 29th, 2024, 7:50 am

String manipulation

Get help with creating, editing & fixing problems with skins
RainyDayBlues
Posts: 3
Joined: September 13th, 2019, 9:22 am

String manipulation

Post by RainyDayBlues »

I have a measure that returns a version value (extracted from a filename, C:\MyPath\ReadMe Rev01.doc), but I want the meter to display the value, 'Rev01' or 'None' fixed text if the version is blank
To do this, I thought I'd use a string measure to process the value obtained, with a RegEx substitute ("^$":"none") but I can't get even the basic string to work.

My measureVersion is either blank or the version text, Rev01, and I can display that in a meter

Code: Select all

[measureReadMe]
Measure=Plugin
Plugin=FileView
Path="C:\MyPath"
ShowDotDot=0
ShowFolder=0
WildcardSearch="ReadMe *.doc"
HideExtensions=1
Count=1
[measureVersion]
Measure=Plugin
Plugin=FileView
Path=[measureReadMe]
Type=Filename
Index=1
Substitute="ReadMe ":""
[measureVersionOrNone]
Measure=String
String=[measureVersion]
If I set the meter to display measureVersion it works, but if I set it to display measureVersionOrNone it is always blank.
If I use String=A[measureVersion]A the meter displays AA

Any ideas?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String manipulation

Post by jsmorley »

If you are going to use that [MeasureVersionOrNone] String measure, then you will need DynamicVariables=1 on it to use the [SectionVariable] as the string value.

However, you don't really need that measure in my view...

Code: Select all

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

[MeasureReadMe]
Measure=Plugin
Plugin=FileView
Path="C:\MyPath"
ShowDotDot=0
ShowFolder=0
WildcardSearch="ReadMe *.doc"
HideExtensions=1
Count=1

[MeasureVersion]
Measure=Plugin
Plugin=FileView
Path=[MeasureReadMe]
Type=Filename
Index=1
RegExpsubstitute=1
Substitute="ReadMe ":"","^$":"None"

;[MeasureVersionOrNone]
;Measure=String
;String=[MeasureVersion]
;DynamicVariables=1

[MeterVersion]
Meter=String
MeasureName=MeasureVersion
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

1.jpg
You do not have the required permissions to view the files attached to this post.
RainyDayBlues
Posts: 3
Joined: September 13th, 2019, 9:22 am

Re: String manipulation

Post by RainyDayBlues »

That's fab, thanks. I had to split the substitutions on 2 lines tho, else it always showed None
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String manipulation

Post by jsmorley »

RainyDayBlues wrote: September 13th, 2019, 10:45 am That's fab, thanks. I had to split the substitutions on 2 lines tho, else it always showed None
No, it shouldn't... I'm not even sure how you "split the substitutions".
RainyDayBlues
Posts: 3
Joined: September 13th, 2019, 9:22 am

Re: String manipulation

Post by RainyDayBlues »

jsmorley wrote: September 13th, 2019, 10:46 am No, it shouldn't... I'm not even sure how you "split the substitutions".
I meant putting the second substitution on a separate line:

Code: Select all

Substitute="ReadMe ":""
Substitute="^$":"None"
However, it is now working the way you said. When you refresh, it puts up 'None' immediately, then updates it to the correct value if the file is found.
Thanks