It is currently April 26th, 2024, 5:17 pm

Special Character "\" at the end of a text chain

Get help with creating, editing & fixing problems with skins
User avatar
Jaime Méndez
Posts: 98
Joined: August 31st, 2022, 10:00 pm

Special Character "\" at the end of a text chain

Post by Jaime Méndez »

Hi everyone!

I need some help. I want a text chaine to be modified in a certain way. Lets say we have the following input:
C:\Documents
but I want a "MeterSection" to add "\" at the end of that string so it would be become as this:
C:\Documents\
but if that chain input already has "\" at the end, nothing would be performed in that MeterSection so the output would finish like this anyway:
C:\Documents\
My input chain has to have "\" at the end no matter if it comes with or without it

Code: Select all

[Path]
Meter=String
MeterStyle=TextStyle
X=([PathBackground:X] + 5)
Y=([PathBackground:Y])
W=([PathBackground:W] - 3)
H=([PathBackground:H])
ClipString=1
MeasureName=mPath
ToolTipText="%1"
Hidden=#HideFile#
Group=Controls
;RightMouseUpAction=[!CommandMeasure mPath "ContextMenu"]
LeftMouseUpAction=[!CommandMeasure "PathEntry" "ExecuteBatch All"]
DynamicVariables=1
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Special Character "\" at the end of a text chain

Post by ikarus1969 »

I would adapt the bounded measure mPath.
Add a

Code: Select all

RegexpSubstitute=1
Substitute="([^\\])$":"\1\"
which means "substitute a non-backslash at the end of the string (whatever this is) by this character and add a backslash"
User avatar
Jaime Méndez
Posts: 98
Joined: August 31st, 2022, 10:00 pm

Re: Special Character "\" at the end of a text chain

Post by Jaime Méndez »

Thank you

It works somehow, but has problems when I don't write exact uppercase letters if there are any in the path string. It is quite estrange for me since it should be non sensitive uppercase letters.

Code: Select all

[mPath]
Measure=Plugin
Plugin=FileView
Path=#Path#
Count=18
ShowDotDot=0
HideExtensions=#Extensions#
DynamicVariables=1

[PathEntry]
Measure=PLUGIN
Plugin=InputText
FontColor=#FontOutline#
SolidColor=#HighlightColor#
FontSize=#FontSize#
X=[PathBackground:X]
Y=[PathBackground:Y]
W=[PathBackground:W]
H=[PathBackground:H]
AntiAlias=1
Command1=[!SetVariable Path """$UserInput$"""][!CommandMeasure "mPath" "Update"][!UpdateMeasure mPath]
FocusDismiss=1
DefaultValue=#Path#
DynamicVariables=1

[Path]
Meter=String
MeterStyle=TextStyle
Substitute="([^\\])$":"\1\"
X=([PathBackground:X] + 5)
Y=([PathBackground:Y])
W=([PathBackground:W] - 3)
H=([PathBackground:H])
ClipString=1
MeasureName=mPath
ToolTipText="%1"
Hidden=#HideFile#
Group=Controls
;RightMouseUpAction=[!CommandMeasure mPath "ContextMenu"]
LeftMouseUpAction=[!CommandMeasure "PathEntry" "ExecuteBatch All"]
DynamicVariables=1
It would loop indefinitely if I write "c:\documents"
It works if I write "C:\Documents"
User avatar
tass_co
Posts: 518
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Special Character "\" at the end of a text chain

Post by tass_co »

Jaime Méndez wrote: October 21st, 2022, 10:58 am Thank you

It works somehow, but has problems when I don't write exact uppercase letters if there are any in the path string. It is quite estrange for me since it should be non sensitive uppercase letters.

Code: Select all

[mPath]
Measure=Plugin
Plugin=FileView
Path=#Path#
Count=18
ShowDotDot=0
HideExtensions=#Extensions#
DynamicVariables=1

[PathEntry]
Measure=PLUGIN
Plugin=InputText
FontColor=#FontOutline#
SolidColor=#HighlightColor#
FontSize=#FontSize#
X=[PathBackground:X]
Y=[PathBackground:Y]
W=[PathBackground:W]
H=[PathBackground:H]
AntiAlias=1
Command1=[!SetVariable Path """$UserInput$"""][!CommandMeasure "mPath" "Update"][!UpdateMeasure mPath]
FocusDismiss=1
DefaultValue=#Path#
DynamicVariables=1

[Path]
Meter=String
MeterStyle=TextStyle
Substitute="([^\\])$":"\1\"
X=([PathBackground:X] + 5)
Y=([PathBackground:Y])
W=([PathBackground:W] - 3)
H=([PathBackground:H])
ClipString=1
MeasureName=mPath
ToolTipText="%1"
Hidden=#HideFile#
Group=Controls
;RightMouseUpAction=[!CommandMeasure mPath "ContextMenu"]
LeftMouseUpAction=[!CommandMeasure "PathEntry" "ExecuteBatch All"]
DynamicVariables=1
It would loop indefinitely if I write "c:\documents"
It works if I write "C:\Documents"

Add to the string meter which displays the returned value the StringCase=Proper option.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Jaime Méndez
Posts: 98
Joined: August 31st, 2022, 10:00 pm

Re: Special Character "\" at the end of a text chain

Post by Jaime Méndez »

I don´t understand. no matter what i do it still loop if i don't write backslash at the end :???:
User avatar
SilverAzide
Rainmeter Sage
Posts: 2611
Joined: March 23rd, 2015, 5:26 pm

Re: Special Character "\" at the end of a text chain

Post by SilverAzide »

Jaime Méndez wrote: October 21st, 2022, 2:37 pm I don´t understand. no matter what i do it still loop if i don't write backslash at the end :???:
You didn't add the Substitute as ikarus1969 described. You put this on the [Path] meter, you need to put both lines he gave you on the [mPath] measure. Substitutes are for measures, not meters.
Gadgets Wiki GitHub More Gadgets...
User avatar
Jaime Méndez
Posts: 98
Joined: August 31st, 2022, 10:00 pm

Re: Special Character "\" at the end of a text chain

Post by Jaime Méndez »

That is what I did first. I put the two lines in [PathEntry] then I started to place it where ever I thought it could help.
I share the entire skin. You´ll find the measure [PathEntry] at "Includes" sub folder of skin directory.

https://forum.rainmeter.net/viewtopic.php?p=210335#p210335
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Special Character "\" at the end of a text chain

Post by ikarus1969 »

Please read my post again, i did not talk about PathEntry, i talked about mPath which should be the measure the meter you posted is bounded to. Add the 2 lines to the measure mPath (or adapt them if already there) and try again