It is currently March 29th, 2024, 11:07 am

Counter not stopping, or: "get back variable to original state"

Get help with creating, editing & fixing problems with skins
derLeon
Posts: 13
Joined: April 19th, 2019, 4:38 pm

Counter not stopping, or: "get back variable to original state"

Post by derLeon »

i try to reset a timer (will later be placed in a other skin). for that i want to have a value for when it is started
how do i get the "vTimeStarted" back to it's original state?
or does anyone have a better idea to stop the counter?

Here is my code. problem is (i think) in line 30

Code: Select all

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

[Variables]
DynamicVariables=1
;variable for "setting time when counting started"
vTimeStartedDebug=[TimeClockGet:Timestamp]
vTimeStarted=[TimeClockGet:Timestamp]
;variable for adjusting time
StopwatchTime=0

DebugNumber=0

;Get time
[TimeClockGet]
Measure=Time
Format=%#I:%M:%S %p

;Calculates the time since it started
[CalcTimeSinceStart]
Measure=Calc
Formula=#vTimeStarted#-[TimeClockGet:Timestamp]+#StopwatchTime#
DynamicVariables=1
IfCondition=CalcTimeSinceStart<=0
IfTrueAction=[!setVariable DebugNumber 1]
IfFalseAction=[!setVariable DebugNumber 0]
IfCondition2=CalcTimeSinceStart<=0
IfTrueAction2=[!SetVariable vTimeStarted [&*TimeClockGet:Timestamp*]
IfCondition3=CalcTimeSinceStart<=0
IfTrueAction3=[!setVariable StopwatchTime 0]

;extrastep for display later in HH:MM:SS
[CalcStopwatchSeconds]
Measure=Calc
Formula=(CalcTimeSinceStart%60)/100
Substitute="0.":""
[CalcStopwatchMinutes]
Measure=Calc
Formula=(Floor(CalcTimeSinceStart/60)%60/100)
Substitute="0.":""
[CalcStopwatchHours]
Measure=Calc
Formula=Floor(CalcTimeSinceStart/3600)/100
Substitute="0.":""
[MeterOne]
DynamicVariables=1
LeftMouseUpAction=[!SetVariable vTimeStarted [TimeClockGet:Timestamp]][!Update]
Meter=String
MeasureName=TimeClockGet
MeasureName2=CalcTimeSinceStart
Text=Started: #vTimeStarted##CRLF#Clock: %1#CRLF#SinceStart: %2

SolidColor=127,127,127,255
FontSize=30
NumOfDecimals=2

[MeterH]
SolidColor=127,127,127,255
FontSize=30
NumOfDecimals=2
DynamicVariables=1
Meter=String
X=r
Y=R
MeasureName=CalcStopwatchHours
Text=%1:
MouseScrollDownAction=[!setVariable StopwatchTime (#StopwatchTime#+3600)>359999?#StopwatchTime#:(#StopwatchTime#+3600)][!Update]
MouseScrollUpAction=[!setVariable StopwatchTime (#StopwatchTime#-3600)<0?#StopwatchTime#:(#StopwatchTime#-3600)][!Update]
[MeterM]
SolidColor=127,127,127,255
FontSize=30
NumOfDecimals=2
DynamicVariables=1
Meter=String
X=R
Y=r
MeasureName=CalcStopwatchMinutes
Text=%1
MouseScrollDownAction=[!setVariable StopwatchTime (#StopwatchTime#+60)>359999?#StopwatchTime#:(#StopwatchTime#+60)][!Update]
MouseScrollUpAction=[!setVariable StopwatchTime (#StopwatchTime#-60)<0?#StopwatchTime#:(#StopwatchTime#-60)][!Update]
[MeterS]
SolidColor=127,127,127,255
FontSize=30
NumOfDecimals=2
DynamicVariables=1
Meter=String
X=R
Y=r
MeasureName=CalcStopwatchSeconds
Text=:%1
MouseScrollDownAction=[!setVariable StopwatchTime (#StopwatchTime#+1)>359999?#StopwatchTime#:(#StopwatchTime#+1)][!Update]
MouseScrollUpAction=[!setVariable StopwatchTime (#StopwatchTime#-1)<0?#StopwatchTime#:(#StopwatchTime#-1)][!Update]
explaination:
with the scrollwheel i can adjust time, then click on the "mainmeter" to start. on zero he should stop.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Counter not stopping, or: "get back variable to original state"

Post by balala »

derLeon wrote: February 7th, 2021, 3:32 am i try to reset a timer (will later be placed in a other skin). for that i want to have a value for when it is started
how do i get the "vTimeStarted" back to it's original state?
or does anyone have a better idea to stop the counter?

Here is my code. problem is (i think) in line 30


explaination:
with the scrollwheel i can adjust time, then click on the "mainmeter" to start. on zero he should stop.
Not sure what would you like to achieve. And what do you mean by "with the scrollwheel i can adjust time"? There is no scroll operation definied in the code.
For now when I click the skin, the numeric value of SinceStart starts to grow (being negative), but that's all. Please describe a little bit more detailed what is your intention.
derLeon
Posts: 13
Joined: April 19th, 2019, 4:38 pm

Re: Counter not stopping, or: "get back variable to original state"

Post by derLeon »

balala wrote: February 7th, 2021, 12:42 pm For now when I click the skin, the numeric value of SinceStart starts to grow (being negative), but that's all.
sorry for my limited abilities at describing problems at coding. i never studied programming or advanced/business english.
english is not my mother tongue. but i still try my best. thanks for patience
balala wrote: February 7th, 2021, 12:42 pm And what do you mean by "with the scrollwheel i can adjust time"? There is no scroll operation definied in the code.
it is. !MouseScrollDownAction and !MouseScrollUpAction at line
69, 70, 81, 82, 93 and 94.
the meter at the bottom for displaying the timer and setting time is the same. these 3 accept input from the mousewheel.
(the start-button should be also there. but for debugging it is more comforting if it has "a bigger button")
also... i want to set hour, minute and seconds seperatly for two reasons: precision and comfort.
balala wrote: February 7th, 2021, 12:42 pm Please describe a little bit more detailed what is your intention.
either
-i want to set back the varible of "vTimeStarted" back to "[TimeClockGet:Timestamp]"

or
-i seek for a different way for writing the code of a timer. (i only found it achieved via extra plugins or scripts. i do not want any of them)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Counter not stopping, or: "get back variable to original state"

Post by balala »

derLeon wrote: February 7th, 2021, 2:44 pm sorry for my limited abilities at describing problems at coding. i never studied programming or advanced/business english.
english is not my mother tongue. but i still try my best. thanks for patience
Don't worry, nor mine. Also try my best.
derLeon wrote: February 7th, 2021, 2:44 pm it is. !MouseScrollDownAction and !MouseScrollUpAction at line
69, 70, 81, 82, 93 and 94.
Right, they are there, indeed. As you see, I many times make such mistakes.
derLeon wrote: February 7th, 2021, 2:44 pm the meter at the bottom for displaying the timer and setting time is the same. these 3 accept input from the mousewheel.
(the start-button should be also there. but for debugging it is more comforting if it has "a bigger button")
also... i want to set hour, minute and seconds seperatly for two reasons: precision and comfort.


either
-i want to set back the varible of "vTimeStarted" back to "[TimeClockGet:Timestamp]"

or
-i seek for a different way for writing the code of a timer. (i only found it achieved via extra plugins or scripts. i do not want any of them)
Let's clarify a few thing for the beginning, because is still not clear enough for me.
When I load the skin, I get the followings:
  • Started: - this is the current time stamp of current time
  • Clock: - returns the current time
  • SincsStart: 0 in the very first moment, starts to count negatively as a decimal number, after first click
  • In the last line, I see the time counting according to the number of seconds shown in the SinceStart line, also with minus signs on each element: hour, minutes and seconds. For instance when the skin starts to count, I get there -01:-01:-01, then the value of the seconds starts increasing.
However even if the scroll are defined onto the MouseScrollDownAction and MouseScrollUpAction options of the [MeterH], [MeterM] and [MeterS] meters, scrolling doesn't change anything. Neither befor the starting click, nor after.
So what I believe, and please confirm or deny, is the following: I believe you'd like to set a time with the mouse scroll (probably on the last, unlabeled line), then when clicking, you'd like to start the countdown, until the time reaches the moment set by the scrolling into the last line. Is this correct?
derLeon
Posts: 13
Joined: April 19th, 2019, 4:38 pm

Re: Counter not stopping, or: "get back variable to original state"

Post by derLeon »

balala wrote: February 7th, 2021, 3:28 pm Don't worry, nor mine. Also try my best.

Right, they are there, indeed. As you see, I many times make such mistakes.

Let's clarify a few thing for the beginning, because is still not clear enough for me.
When I load the skin, I get the followings:
  • Started: - this is the current time stamp of current time
  • Clock: - returns the current time
  • SincsStart: 0 in the very first moment, starts to count negatively as a decimal number, after first click
  • In the last line, I see the time counting according to the number of seconds shown in the SinceStart line, also with minus signs on each element: hour, minutes and seconds. For instance when the skin starts to count, I get there -01:-01:-01, then the value of the seconds starts increasing.
However even if the scroll are defined onto the MouseScrollDownAction and MouseScrollUpAction options of the [MeterH], [MeterM] and [MeterS] meters, scrolling doesn't change anything. Neither befor the starting click, nor after.
So what I believe, and please confirm or deny, is the following: I believe you'd like to set a time with the mouse scroll (probably on the last, unlabeled line), then when clicking, you'd like to start the countdown, until the time reaches the moment set by the scrolling into the last line. Is this correct?
sorry i answer so late. i did put the project aside a few days and forget it then

Image
scrolling with the mouse hovering at where now is "07:06:09" does increase and decrease the countdown timer, depends on up or down scroll

your assumption is correct. but in reverse
the -1 is the problem. -1 should not happen.
if sinceStart reaches 0 it should stop.
derLeon
Posts: 13
Joined: April 19th, 2019, 4:38 pm

Re: Counter not stopping, or: "get back variable to original state"

Post by derLeon »

PS: naming it "sinceStart" seems a BIT missleading. oops
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Counter not stopping, or: "get back variable to original state"

Post by balala »

derLeon wrote: May 3rd, 2021, 5:30 pm your assumption is correct. but in reverse
the -1 is the problem. -1 should not happen.
if sinceStart reaches 0 it should stop.
There is a small mistake in the IfTrueAction2 option of the [CalcTimeSinceStart] measure. This option was written this way in your original code:IfTrueAction2=[!SetVariable vTimeStarted [&*TimeClockGet:Timestamp*]. As you can see I colored the brackets and this way you can see that the first bracket (the red one above), has no closing pair. This is why the option doesn't work. However, weird is that there is no error message in the log. Not sure why...
The fix is pretty easy: add the missing characters. Something like this: IfTrueAction2=[!SetVariable vTimeStarted "[&*TimeClockGet:Timestamp*]"] (see that beside the missing bracket, I also added quotes, which are not absolutely required, but it's always a good idea to get used to use them).
derLeon wrote: May 3rd, 2021, 5:33 pm PS: naming it "sinceStart" seems a BIT missleading. oops
No problem from the point of view of the skin. It does perfectly works, however are you name it.
derLeon
Posts: 13
Joined: April 19th, 2019, 4:38 pm

Re: Counter not stopping, or: "get back variable to original state"

Post by derLeon »

balala wrote: May 3rd, 2021, 6:05 pm has no closing pair.
genius. thanks. now it works like it should.
i knew timers are possoible without plugins.
will later make a shutdown timer of it and post the full skin when it is finished :D
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Counter not stopping, or: "get back variable to original state"

Post by balala »

derLeon wrote: May 5th, 2021, 4:57 am genius. thanks. now it works like it should.
Great! :thumbup:
derLeon wrote: May 5th, 2021, 4:57 am i knew timers are possoible without plugins.
will later make a shutdown timer of it and post the full skin when it is finished :D
Are definitely.
SELF PROMOTION: The Timer skin of my Mirage suite has more functions: a timer, a countdown, a data traffic watcher and a stopwatch. The first three can shutdown, logoff, sleep, hibernate (and so on) the computer when the preset moment is reached, the preset time goes by or the data trafic decreases (the Stopwatch has no such features, as its name says, it's just a simple stopwatch). All this are done without using a plugin (well in fact the skin uses two plugins, the built in RunCommand and the ActionTimer plugins, but those are not related on how the skin is doing its job).