Created
January 14, 2023 14:38
-
-
Save AndyPiddock/2fd72b7f68cac6d3f58146ef2b50bdda to your computer and use it in GitHub Desktop.
Countdown Timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tCountdown | |
function countdown pPeriod, pAction | |
set the numberFormat to "00." | |
if pAction = "Start" then | |
put pPeriod into tCountdown | |
repeat while tCountdown > -1 | |
put tCountdown div 60 & ":" & (tCountdown mod 60) into field "timer" | |
wait 1 second with messages | |
subtract 1 from tCountdown | |
if tCountdown = 0 then | |
put"times uop" | |
end if | |
end repeat | |
else if pAction = "Stop" then | |
put 0 into tCountdown | |
put tCountdown div 60 & ":" & (tCountdown mod 60) into field "timer" | |
end if | |
end countdown | |
Usage examples | |
on mouseUp | |
get countdown(300, "Start") | |
end mouseUp | |
on mouseUp | |
get countdown(0, "Stop") | |
end mouseUp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment