Skip to content

Instantly share code, notes, and snippets.

@AndyPiddock
Created January 14, 2023 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyPiddock/2fd72b7f68cac6d3f58146ef2b50bdda to your computer and use it in GitHub Desktop.
Save AndyPiddock/2fd72b7f68cac6d3f58146ef2b50bdda to your computer and use it in GitHub Desktop.
Countdown Timer
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