Dynamically. They will be set by a !SetVariable bang.jsmorley wrote:So how are the initial values received?
It is currently April 26th, 2024, 5:52 am
Convert lowercase to uppercase
-
- Rainmeter Sage
- Posts: 16172
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Convert lowercase to uppercase
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert lowercase to uppercase
I need to understand what is going to trigger updating the String measure, which will then do the !WriteKeyValue when it is updated.balala wrote:Dynamically. They will be set by a !SetVariable bang.
-
- Rainmeter Sage
- Posts: 16172
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Convert lowercase to uppercase
When the Path variable is set (through a !SetVariable bang), the String measure should have to be updated and this one should have to make the appropriate substitution, if it's possible (so, if the set variable is a a path of a file contained into the @Resources folder of the current config).jsmorley wrote:I need to understand what is going to trigger updating the String measure, which will then do the !WriteKeyValue when it is updated.
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert lowercase to uppercase
Skin:
Lua:
Does that make some sense?
I caution that this will likely not work well with multi-byte Unicode characters in the @Resources path, as that can and will throw off things that are dependent on "string length". The only solution for that is to convert the path to upper case in the Lua, and then use string.gsub() which is not dependent on the position of anything in the string. That will mean that the result that is written will have to be upper case though.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
@Include=#CURRENTPATH#MyVars.inc
[Lua]
Measure=Script
ScriptFile=Test.lua
Disabled=1
[MeasurePath]
Measure=String
Disabled=1
UpdateDivider=-1
DynamicVariables=1
OnUpdateAction=[!WriteKeyValue Variables Path1 "[Lua:ReplaceResources('[#Path1]')]" "[#CURRENTPATH]MyVars.inc"]
[MeterChange]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=Update
LeftMouseUpAction=[!SetVariable Path1 "c:\Users\jeffrey\Documents\Rainmeter\Skins\@Working\@Resources\SomeImage.png"][!EnableMeasure MeasurePath][!UpdateMeasure MeasurePath]
Code: Select all
function ReplaceResources(inArg)
MyResources = SKIN:GetVariable('@')
startResources, endResources = string.find(string.upper(inArg), string.upper(MyResources))
if startResources then
return '#@#'..string.sub(inArg, endResources + 1)
else
return inArg
end
end
I caution that this will likely not work well with multi-byte Unicode characters in the @Resources path, as that can and will throw off things that are dependent on "string length". The only solution for that is to convert the path to upper case in the Lua, and then use string.gsub() which is not dependent on the position of anything in the string. That will mean that the result that is written will have to be upper case though.
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert lowercase to uppercase
That would look like:
But you would end up with:
To be honest, string "case" is just a matter of cosmetics in any path you use with Windows. It doesn't care. Paths and file names are never case sensitive.
Code: Select all
function ReplaceResources(inArg)
myResources = SKIN:GetVariable('@')
outArg = string.gsub(string.upper(inArg), string.upper(myResources), '#@#')
return outArg
end
Code: Select all
[Variables]
Path1=#@#SOMEIMAGE.PNG
-
- Rainmeter Sage
- Posts: 16172
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Convert lowercase to uppercase
Yep, it does and works for now. Will have to study the code of the .lua file, to better understand how does it work. But it seems that definitely works.jsmorley wrote:Does that make some sense?
Many thanks for your help.
At least for now this isn't a problem, I used just simple letters, without diacritics, I hope will be no problems with this.jsmorley wrote:I caution that this will likely not work well with multi-byte Unicode characters in the @Resources path, as that can and will throw off things that are dependent on "string length". The only solution for that is to convert the path to upper case in the Lua, and then use string.gsub() which is not dependent on the position of anything in the string. That will mean that the result that is written will have to be upper case though.
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert lowercase to uppercase
The problem would come if the users name or any other part of the path has multi-bye Unicode like 某些文件夹
-
- Rainmeter Sage
- Posts: 16172
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Convert lowercase to uppercase
No problem!jsmorley wrote:But you would end up with:
Code: Select all
[Variables] Path1=#@#SOMEIMAGE.PNG
Yes, I know. The initial question came when I wanted to make the Substitute="#@#":"#*@*#" substitution (didn't think yet to the reserved character issue then), but due to the lowercase drive letter in the Path variable, the substitution wasn't made.jsmorley wrote:To be honest, string "case" is just a matter of cosmetics in any path you use with Windows. It doesn't care. Paths and file names are never case sensitive.
-
- Rainmeter Sage
- Posts: 16172
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Convert lowercase to uppercase
I think there is no (good) solution for this?jsmorley wrote:The problem would come if the users name or any other part of the path has multi-bye Unicode like 某些文件夹
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert lowercase to uppercase
Right, I'm just saying that case isn't important to Windows, so if you store the path variables in the .inc file in upper case, it will work fine, unless you are "displaying" the path in the skin, in which case converting to upper case might not look great. So my first approach maintains the case as is, but will have trouble with Unicode, and the second is more certain, but will have the cosmetic issue.balala wrote:No problem!
Yes, I know. The initial question came when I wanted to make the Substitute="#@#":"#*@*#" substitution (didn't think yet to the reserved character issue then), but due to the lowercase drive letter in the Path variable, the substitution wasn't made.