Lucas_3D

stopwatch

Jul 16th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. (
  2. local startTime
  3. local stopTime
  4. local startTheClock = false
  5. try destroyDialog ::roStopwatch catch()
  6. rollout roStopwatch "Stopwatch"
  7. (
  8. button btnStart "Start" width:100 height:25 across:2
  9. button btnStop "Stop" width:100 height:25
  10. label lblTime "" align:#left offset:[75,0]
  11. -- timer timerDisplay "" interval:50 --tick once a second
  12. -- on timerDisplay tick do
  13. -- (
  14. -- if startTheClock == true do
  15. -- (
  16. -- lblTime.text = ((timeStamp() - startTime) / 1000.0) as string
  17. -- )
  18. -- )
  19. on btnStart pressed do
  20. (
  21. startTime = timeStamp()
  22. startTheClock = true
  23. )
  24. on btnStop Pressed do
  25. try(
  26. startTheClock = false
  27. stopTime = timeStamp()
  28. timeTaken = ((stopTime - startTime) / 1000.0)
  29. lblTime.text = timeTaken as string + " Seconds"
  30. )catch()
  31. )
  32. createDialog roStopwatch width:230 height:60 pos:[10,150]
  33. )
Add Comment
Please, Sign In to add comment