It is currently October 24th, 2024, 1:28 am

Case Conversion: measure or meter

Get help with creating, editing & fixing problems with skins
User avatar
qwerky
Posts: 244
Joined: April 10th, 2014, 12:31 am
Location: Canada

Case Conversion: measure or meter

Post by qwerky »

Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?

Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
User avatar
jsmorley
Developer
Posts: 22883
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Case Conversion: measure or meter

Post by jsmorley »

qwerky wrote: October 22nd, 2024, 9:07 pm Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?

Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
I think the best way is a very simple Lua function:

https://docs.rainmeter.net/manual/lua-scripting/inline-lua/

Test.lua:

Code: Select all

function Upper(inString)
	return string.upper(inString)
end
Test.ini:

Code: Select all

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

[Variables]

[Lua]
Measure=Script
ScriptFile=Test.lua
Disabled=1

[MeasureString]
Measure=String
String=bc

[MeterString]
Meter=String
Text=[&Lua:Upper('[&MeasureString]')]
FontSize=16
SolidColor=0,0,0,1
FontColor=255,255,255,255
AntiAlias=1
ToolTipText=[&Lua:Upper('[&MeasureString]')]
DynamicVariables=1
Up to you where you use the Inline Lua function call, it will work almost anywhere. Note that DynamicVariables=1 will be required most, but not all, places you use it.

1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 8550
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Case Conversion: measure or meter

Post by Yincognito »

qwerky wrote: October 22nd, 2024, 9:07 pm Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?

Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
Indeed, neither the Inline Case, nor the StringCase in a String meter would work for tooltips, though they would work just fine for either parts or the entire contents of the String meter itself. Regex support for \U is quite rare, and unavailable in Rainmeter as well - even regex101.com mentions that the feature is only available on their site. I believe jsmorley's advice is a very simple one to follow, especially if we're talking about tooltips, where other features that Rainmeter provides are limited.

By the way, Rainmeter does not do regex patterns (bar the \1, \2 and such references) in the 2nd part of the substitution, i.e. the one after the : symbol. I'm saying this because I've seen other applications do it (which would be where the \U part is written, if it were to be possible).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
qwerky
Posts: 244
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Case Conversion: measure or meter

Post by qwerky »

jsmorley wrote: October 22nd, 2024, 9:28 pm I think the best way is a very simple Lua function:
Thank you! This works great. And thanks for such a quick response. :cheer:
User avatar
qwerky
Posts: 244
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Case Conversion: measure or meter

Post by qwerky »

Yincognito wrote: October 22nd, 2024, 9:51 pm By the way, Rainmeter does not do regex patterns (bar the \1, \2 and such references) in the 2nd part of the substitution, i.e. the one after the : symbol. I'm saying this because I've seen other applications do it (which would be where the \U part is written, if it were to be possible).
And thank you too for the quick response. That's good information to be aware of. :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 8550
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Case Conversion: measure or meter

Post by Yincognito »

Out of curiosity, how come the province codes are lower case on that site? It's almost an unwritten standard for them to be upper case, and especially if they are initials of different names (i.e. different words) ... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
qwerky
Posts: 244
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Case Conversion: measure or meter

Post by qwerky »

Yincognito wrote: October 22nd, 2024, 10:14 pm Out of curiosity, how come the province codes are lower case on that site? It's almost an unwritten standard for them to be upper case, and especially if they are initials of different names (i.e. different words) ... :???:
That's a very good question! That site also has lower-case for the current station code (the airport code -- YVR, which in my experience is also usually upper-case); but on the other hand, it does have the timezone code (PDT) in upper-case. :Whistle Wish I could find some better documentation for that site.

BTW, I just noticed that this forum's smilies have changed. I thought there used to be a :shrug:, but maybe not. ;)
User avatar
qwerky
Posts: 244
Joined: April 10th, 2014, 12:31 am
Location: Canada

Re: Case Conversion: measure or meter

Post by qwerky »

jsmorley wrote: October 22nd, 2024, 10:42 pm :confused:

So not that?
But, but, but... I guess that must be the one I was thinking of, though it is called "confused" rather than "shrug". But hey, close enough. :D
User avatar
jsmorley
Developer
Posts: 22883
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Case Conversion: measure or meter

Post by jsmorley »

qwerky wrote: October 22nd, 2024, 10:54 pm But, but, but... I guess that must be the one I was thinking of, though it is called "confused" rather than "shrug". But hey, close enough. :D
Search around on the interwebs, and if you find a reasonably small animated gif "shrug" smiley. Attach it here and I will gladly add it.

¯\_(ツ)_/¯
RicardoTM
Posts: 411
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Case Conversion: measure or meter

Post by RicardoTM »

jsmorley wrote: October 22nd, 2024, 10:56 pm Search around on the interwebs, and if you find a reasonably small animated gif "shrug" smiley. Attach it here and I will gladly add it.

¯\_(ツ)_/¯
Got bored, made this:
shrug.gif
and here a little slower
shrugslower.gif
and here with a bit different expression
shrug2.gif
You do not have the required permissions to view the files attached to this post.