Nautical bell: Difference between revisions

m
→‎{{header|AppleScript}}: Minor change to headings.
(→‎{{header|AppleScript}}: Added 'idle' handler version.)
m (→‎{{header|AppleScript}}: Minor change to headings.)
Line 18:
=={{header|AppleScript}}==
 
===repeatContinuous looprepeat===
 
This version uses local time and speaks the bell rings using OS X's built-in speech synthesizer.
Line 38:
end repeat</lang>
 
==='idle' handler===
 
For actions which are to be carried out at set intervals throughout the day, it's more usual to use a stay-open script applet with an 'idle' handler. When such an applet's launched, it sits there mostly doing nothing until it receives an 'idle' command from the system, whereupon it performs the actions in its 'idle' handler. If this handler returns a positive number (or something that can be interpreted as one), the system takes this as the number of seconds to wait before sending another 'idle' command to the applet. Otherwise the default is thirty seconds. This hogs the processor far less than having the script run on a continuous repeat. Unfortunately, depending on how busy the computer is at the time, 'idle' calls may be slightly delayed, so any time checks performed by the handler have to allow for this.
557

edits