Timer as stop watch Question

Good Day all,

most may think this a trivial effort but it is one I would like to solve. I have a Timer, 1 textbox which displays the running state of the timer. 2 numeric textboxes, and a button. One numeric textbox is called Seconds. it has an expression linking to the timer value so it will display the timer count. The timer Value is 0, Step by 1, bound by 60. I also have a property change script on it that says

if event.source.intValue == 59:
event.source.parent.getComponent(‘Minutes’).intValue =
event.source.parent.getComponent(‘Minutes’).intValue + 1

The other numeric textbox is for the result of minutes. The button activates, and stops the timer.

My issue is that the increment is always by 5 instead of 1. so each time the timer reaches 59 it add another 5 to the minutes instead of 1. I can’t seem to figure out how to just add 1.

The propertyChanged call will execute for every change. So you need to check the propertyName of the even if you only want to react to one particular event.

That said, if you just want to display the elapsed time, it might be better by setting a starttime on some custom parameter, and using the expression bindings to calculate the time difference between the starttime and now, and format that time.

Thank you for your reply. I have read some other suggestions on using timestamp. I was just looking at showing an actual Seconds and minutes count on the window from a start trigger to a stop trigger then record the final minutes total.

I got this working the way I wanted it to for anyone in the future who may be interested.

Timer Settings:
Value: 0
Step by: 1
Bound: 60

Timer State Text Box shows off or on. determined by button script.

Button which is scripted to start or stop the timer and populate the State Text Box:
if event.source.parent.getComponent(‘Timer’).running is False:
event.source.parent.getComponent(‘Timer’).running = True
event.source.parent.getComponent(‘TimerOnOff’).text = “On”
event.source.parent.getComponent(‘Timer’).running = False
event.source.parent.getComponent(‘TimerOnOff’).text = “Off”
event.source.parent.getComponent(‘Timer’).value = 0
event.source.parent.getComponent(‘Minutes’).intValue = 0

Seconds Numeric Text Box Property Value(Integer) is linked by expression to to the Timer Value to show seconds.

Minutes Numeric Text Box Is linked to nothing, and no Scripts.

On the Timer Action Performed I added the following Script:
if event.source.value == 59:
event.source.parent.getComponent(‘Minutes’).intValue = event.source.parent.getComponent(‘Minutes’).intValue + 1

Now every 59 seconds I get an increment of 1 in the minutes Text Box.

Thanks again for the help.

1 Like