It is currently September 18th, 2019, 12:10 am

Loading Value from TextFile into RoundLine

Help with creating, editing & fixing problems with skins
photozero
Posts: 2
Joined: August 26th, 2019, 2:12 pm

Loading Value from TextFile into RoundLine

photozero » August 26th, 2019, 2:22 pm

I am trying to do what I think should be super simple but keep coming up short.

Basically what I want to do is be able to read from a text file that will only have the value say 20000.
I then want to display a RoundLine that shows the percentage remaining till 50000.
I can load the value, but every time the RoundLine shows up as 100%

I think it has to do with for whatever reason the value can not be converted to a number.
Is there something I should be doing to the value after it is read in to make sure it is perceived as a number?

I have tried this numerous ways but nothing seems to work so not sure where I am going wrong.

TIA
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Loading Value from TextFile into RoundLine

jsmorley » August 26th, 2019, 2:28 pm

The issue is that while the string "20000" that you are getting can be seen as a number, you need to explicitly set the MinValue/MaxValue options on the measure returning it, so it can be used as a percentage.

If you do something like this:

Code: Select all

[MyMeasure]
Measure=String
String=20000
MinValue=0
MaxValue=50000
Then you can use the measure [MyMeasure] as input to a Roundline and it will work fine. I'm just using a String measure as an example, yours might be a QuotePlugin measure or a WebParser measure or a Lua measure or whatever.

It may be counter-intuitive that you can set an explicit MinValue/MaxValue on a measure that by its nature returns only a string value, but as long as the string is entirely numeric, you can. Rainmeter is no end of clever...
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Loading Value from TextFile into RoundLine

jsmorley » August 26th, 2019, 9:18 pm

As an additional note that folks might put in their hip-pocket... This will be on the quiz.

While the above is true if the string value of a measure is entirely numeric, this is only true if the string is numeric in the first instance. By that, I mean it won't work if you trick the measure into being numeric with a Substitute option.

Works fine:
Returns 40%.

Code: Select all

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

[MyMeasure]
Measure=String
String=20000
MinValue=0
MaxValue=50000

[MeterPercent]
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=[MyMeasure:%]%
Won't work:
While the string value will in fact become "20000", it's too late, the number value is already invalid, or zero. You don't get a second bite at the apple.

Code: Select all

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

[MyMeasure]
Measure=String
String=Twenty Thousand
Substitute="Twenty Thousand":"20000"
MinValue=0
MaxValue=50000

[MeterPercent]
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=[MyMeasure:%]%
How to make that work:
The second String measure is numeric in the first instance, and so all is well, the number value will be 20000.

Code: Select all

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

[MyMeasure]
Measure=String
String=Twenty Thousand
Substitute="Twenty Thousand":"20000"

[MyMeasureNumeric]
Measure=String
String=[MyMeasure]
DynamicVariables=1
MinValue=0
MaxValue=50000

[MeterPercent]
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=[MyMeasureNumeric:%]%
Just remember, Substitute ONLY acts on the "string" value of a measure, and will be done "after" the cleverness that transforms a numeric string into an actual number value on the measure. The Substitute action is actually not done on the measure creating the string value, but on whatever is later "asking" for the string value. [MyMeasureNumeric] is "asking" for the string value of [MyMeasure], and that will in fact be "20000" and with MinValue/MaxValue can be used as a percentage.
photozero
Posts: 2
Joined: August 26th, 2019, 2:12 pm

Re: Loading Value from TextFile into RoundLine

photozero » August 27th, 2019, 4:02 pm

Thank you so much.
Been working on this quite a bit in my spare time. It was a very trivial thing but I have a facebook news page that I track a lot of stats on (like hourly likes,etc)
I thought it would be neat showing my progression towards 50k likes. I am new to skin development and thought this didn't seem too complicated but after looking at your code I saw a few of my mistakes. 10 minutes after reading your post it is all working now.

Thank you again!
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Loading Value from TextFile into RoundLine

jsmorley » August 27th, 2019, 5:46 pm

Glad to help!