It is currently May 6th, 2024, 10:38 am

How to count letters from a string?

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to count letters from a string?

Post by jsmorley »

Don't mean to hijack or sidetrack this thread, but since this whole discussion started back in the day, we have added Lua scripting to Rainmeter, and this might be another alternative:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[TITLEcounted]
measure=plugin
Plugin=NowPlaying.dll
PlayerName=iTunes
PlayerType=title

[MeasureLuaScript]
Measure=Script
ScriptFile=Test.lua

[countTITLEstring]
meter=string
FontColor=255,255,255,255
SolidColor=0,0,0,1
text=There are [MeasureLuaScript] characters in [TITLEcounted].
DynamicVariables=1
Test.Lua:

Code: Select all

PROPERTIES =
{
}

function Initialize()

	msMeasure = SKIN:GetMeasure('TITLEcounted')

end

function Update()

   sTitle = msMeasure:GetStringValue()
   
   return sTitle:len()

end
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: How to count letters from a string?

Post by Brian »

The more the merrier. I like how there is more than 1 solution to problems, just shows how robust Rainmeter really is.

-Brian
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: How to count letters from a string?

Post by Brian »

Just in case you still wanted to use the "Title" of the track AND still use the count, then you could make a secondary measure like this:

Code: Select all

[TITLE]
measure=plugin
Plugin=NowPlaying.dll
PlayerName=iTunes
PlayerType=title

[TITLEcounted]
measure=plugin
Plugin=NowPlaying.dll
PlayerName=[TITLE]
PlayerType=title
RegExpSubstitute=1
Substitute="[\s\d\D]":"1+"
This way [TITLE] would not be changed by the substitute. JSMorley's lua script avoids this as well.

-Brian