It is currently May 8th, 2024, 8:00 am

Uptime Question (need help again)

Get help with creating, editing & fixing problems with skins
Wolfgang DelaSangre
Posts: 35
Joined: December 14th, 2010, 6:11 am

Uptime Question (need help again)

Post by Wolfgang DelaSangre »

Is there a way to hide individual values shown by an System Uptime skin if they are equal to 0? I mean, if my computer hasn't even been on for a whole day, how do I hide the bit that says "0 days"? Is it even possible?
Last edited by Wolfgang DelaSangre on March 19th, 2011, 10:37 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Uptime Question

Post by jsmorley »

[Rainmeter]
DynamicWindowSize=1
Update=1000

[Variables]
DynamicFormat=""

[MeasureUpTimeDays]
Measure=UpTime
Format=%4!i!

[MeasureCalcToSetFormat]
Measure=Calc
Formula=[MeasureUpTimeDays]
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable DynamicFormat "%4!i! Days, %3!i! Hours, %2!i! Minutes %1!i! Seconds"
IfBelowValue=1
IfBelowAction=!RainmeterSetVariable DynamicFormat "%3!i! Hours, %2!i! Minutes %1!i! Seconds"
DynamicVariables=1

[MeasureRealUpTime]
Measure=UpTime
Format=#DynamicFormat#
DynamicVariables=1

[MeterUpTime]
Meter=String
MeasureName=MeasureRealUpTime
X=0
Y=0
FontSize=15
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=System UpTime: %1
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Uptime Question

Post by poiru »

A more simple approach would be:

[MeasureUpTime]
Measure=UpTime
Format=".%4!i! Days, %3!i! Hours, %2!i! Minutes, %1!i! Seconds"
Substitute=".0 Days":"",".":""

In case you're wondering, the period at the beginning is to stop "10 Days", for example, from being substituted.
Wolfgang DelaSangre
Posts: 35
Joined: December 14th, 2010, 6:11 am

Re: Uptime Question

Post by Wolfgang DelaSangre »

Awesome. Thanks, guys. I think I get it now.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Uptime Question

Post by jsmorley »

poiru wrote:A more simple approach would be:

[MeasureUpTime]
Measure=UpTime
Format=".%4!i! Days, %3!i! Hours, %2!i! Minutes, %1!i! Seconds"
Substitute=".0 Days":"",".":""

In case you're wondering, the period at the beginning is to stop "10 Days", for example, from being substituted.
Doh! Of course... Sure, undercut my selling solutions by weight! :-)
Wolfgang DelaSangre
Posts: 35
Joined: December 14th, 2010, 6:11 am

Re: Uptime Question

Post by Wolfgang DelaSangre »

Reviving this topic because another problem has come up.

I took Poiru's solution and tried applying it to the whole thing. This is what it looks like right now.

Code: Select all

[MeasureUpTime]
Measure=UpTime
Format=".%4!i! days, .%3!i! hours and .%2!i! minutes"
Substitute=".0 days, ":"",", .0 hours":"",".0 hours and ":""," and .0 minutes":"",".1 days":".1 day",".1 hours":".1 hour",".1 minutes":".1 minute",".%4!i! days, .%3!i! hours and .0 minutes":".%4!i! days and .%3!i! hours",".":""
The problem is that I can't get it to show "X days and X hours". It always shows "X days, X hours". Does anyone know why this is?
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Uptime Question (need help again)

Post by poiru »

Try:

[MeasureUpTime]
Measure=UpTime
Format=".%4!i! days and .%3!i! hours and .%2!i! minutes"
Substitute=".0 days and ":"",".1 days":"1 day",".0 hours and ":"",".1 hours":"1 hour"," and .0 minutes":"",".1 minutes":"1 minute",".":""
Wolfgang DelaSangre
Posts: 35
Joined: December 14th, 2010, 6:11 am

Re: Uptime Question (need help again)

Post by Wolfgang DelaSangre »

Won't that end up showing "X days and" if the other two values are 0?

Decided to try a more direct approach, but that doesn't seem to be working either.

Code: Select all

[MeasureUpTime]
Measure=UpTime
Format=".%4!i! days, .%3!i! hours and .%2!i! minutes"
Substitute=".%4!i! days, .%3!i! hours and .0 minutes":".%4!i! days and .%3!i! hours",".%4!i! days, .0 hours and .%2!i! minutes":".%4!i! days and .%2!i! minutes",".0 days, .%3!i! hours and .%2!i! minutes":".%3!i! hours and .%2!i! minutes",".%4!i! days, .0 hours and .0 minutes":".%4!i! days",".0 days, .%3!i! hours and .0 minutes":".%3!i! hours",".0 days, .0 hours and .%2!i! minutes":".%2!i! minutes",".":""
Exact same problem, except now it's showing "X days, X hours and 0 minutes". How come it simply will not acknowledge this substitute command, but all the others are fair game?
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Uptime Question (need help again)

Post by poiru »

Wolfgang DelaSangre wrote:Won't that end up showing "X days and" if the other two values are 0?
I haven't tested, but if my thinking was correct, it should show "X days" (without the "and") if the other two are 0. I thought about several cases, and they all give a "proper" result. Give it a shot and let me know if it works.

By the way, your substitutes don't work because you can't use the % stuff in them (they have no meaning there, to put it simply).
Wolfgang DelaSangre
Posts: 35
Joined: December 14th, 2010, 6:11 am

Re: Uptime Question (need help again)

Post by Wolfgang DelaSangre »

Yeah, I just restarted the computer and figured that out. Can't figure out for the life of me how to get that comma to change to an " and "if the percents don't matter, though.

I guess the only solution is to write subs for each possibility. Or find some clever trick I can do with the calc thing.