It is currently October 15th, 2024, 8:43 am

New Measure=String

Changes made during the Rainmeter 3.1 beta cycle.
User avatar
jsmorley
Developer
Posts: 22856
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New Measure=String

Post by jsmorley »

We have added a new Measure=String measure type to Rainmeter.

The only measure-specific option currently needed is String.

Code: Select all

[MeasureMyString]
Measure=String
String=Hello World
This can be used to have a reliable and easy place to manipulate a string, using variables or section variables and RegExpSubstitute / Substitute to create and modify the string value.

This is intended to address obtaining a string or numeric-string value (using measures like WebParser or QuotePlugin or FileView) and manipulating the string while keeping the original value and format for other purposes. Previously, we either needed to create two of the measures, which is inefficient at best, or use the Time measure, which has the disadvantage of failing if any "%" character is used in the string. ("%" is a component of a Time code, and will confuse the measure if used in a normal string)

The measure can also be very handy for prototyping and testing skin functionality where you need to use a string obtained by a more complicated process like parsing a web site or obtaining input from a user with InputText or other methods that are time consuming to create. Simply use a String measure to create an example of the string value you intend to obtain, and use it in place of the more complicated functions while you test how you are going to "use" the value in your skin.

The following code demonstrates one use of the new measure.

Measure=String

Code: Select all

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

[MeasureNumber]
Measure=Calc
Formula=(2**31)

[MeasureString]
Measure=String
String=[MeasureNumber]
RegExpSubstitute=1
Substitute="\d{1,3}(?=(\d{3})+$)":"\0,"
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureNumber
FontSize=13
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
AutoScale=1
Text=[MeasureString:]#CRLF#%1B#CRLF#[MeasureString]
DynamicVariables=1
2014-01-03_120343.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: New Measure=String

Post by moshi »

nice to have. until now i always used a Calc measure with Formula=1 and Substitute="1":"whatever"
User avatar
jsmorley
Developer
Posts: 22856
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Measure=String

Post by jsmorley »

moshi wrote:nice to have. until now i always used a Calc measure with Formula=1 and Substitute="1":"whatever"
Yes, mostly we just wanted a way to create and manipulate a string that didn't involve explaining "the trick" each and every time we used it. What we have used up to now, using a Time measure or a Calc / Substitute approach, are just so spectacularly non-obvious to a new user, that I almost felt like apologizing every time I used them trying to help someone.

Then when we added IfMatch, it really became desirable to address this. Since Substitute isn't about changing a measure's value, only about changing how other objects "see" the value, if you use the Calc / Substitute approach you can't do the IfMatch right on the same measure. So you had to create yet another bogus measure just do do the testing.

The String measure is both easy to understand for the newest user, and involves the least amount of slight-of-hand.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: New Measure=String

Post by Virginityrocks »

If I'm understanding this correctly, this means that instead of having a measure, then a string which references that measure, both the string and the measure can be put into one? How much CPU does this save? Or is this mainly just to make things easier to read, write, and understand?
Droptop Four
Dropdown menu bar & app launcher for Windows & Rainmeter
User avatar
jsmorley
Developer
Posts: 22856
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Measure=String

Post by jsmorley »

Virginityrocks wrote:If I'm understanding this correctly, this means that instead of having a measure, then a string which references that measure, both the string and the measure can be put into one? How much CPU does this save? Or is this mainly just to make things easier to read, write, and understand?
It's mostly to replace the old method of using a Time measure when you wanted to have a place to manipulate a string. It can be used with Substitute, or with IFMatch, or anything else that acts on the string value of a measure. The disadvantage of how we used to use the Time measure for this is that any "%" character in the string will just give it fits, as that is the character used to indicate a "time code".