Nautical bell: Difference between revisions
Content added Content deleted
m (wiki syntax) |
m (whitespace/tidy up) |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
⚫ | |||
The task is to write a small program that emulates a [ |
The task is to write a small program that emulates a [[wp:Ship's bell#Timing_of_duty_periods|nautical bell]] producing a ringing bell pattern at certain times throughout the day. |
||
⚫ | |||
⚫ | |||
It is permissible for the program to [[Run as a daemon|daemonize]], or to slave off a scheduler, and it is permissible to use alternative notification methods (such as producing a written notice "Two Bells Gone"), if these are more usual for the system type. |
It is permissible for the program to [[Run as a daemon|daemonize]], or to slave off a scheduler, and it is permissible to use alternative notification methods (such as producing a written notice "Two Bells Gone"), if these are more usual for the system type. |
||
⚫ | |||
=={{header|D}}== |
=={{header|D}}== |
||
⚫ | |||
⚫ | |||
<lang d>import std.stdio, core.thread, std.datetime; |
<lang d>import std.stdio, core.thread, std.datetime; |
||
Line 70: | Line 65: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
The local time is used instead of Greenwich mean time. |
The local time is used instead of Greenwich mean time. |
||
If any arguments are specified, that text is used as a prefix to the times shown (once a minute). |
|||
Also, the number of bells sounded are shown (if any arguments are specified). |
|||
If no arguments are specified, no times are shown. |
|||
In all cases, the PC speaker is used to sound the bells (albeit a poorly sounded bell). |
|||
<br><br>This REXX program makes use of '''DELAY''' BIF which delays (sleeps) for a specified amount of seconds. |
|||
<br>Some REXXes doen't have a '''DELAY''' BIF, so one is included here ──► [[DELAY.REX]]. |
|||
This REXX program makes use of <code>DELAY</code>, BIF which delays (sleeps) for a specified amount of seconds (some REXXes doen't have a <code>DELAY</code> BIF, so one is included [[DELAY.REX|here]]), and <code>SOUND</code> BIF, which produces sounds via the PC speaker (some REXXes doen't have a <code>SOUND</code> BIF, so one is included [[SOUND.REX|here]]). |
|||
<br>Some REXXes doen't have a '''SOUND''' BIF, so one is included here ──► [[SOUND.REX]]. |
|||
<lang rexx>/*REXX pgm sounds "bells" (using PC speaker) when running (perpetually).*/ |
<lang rexx>/*REXX pgm sounds "bells" (using PC speaker) when running (perpetually).*/ |
||
echo= arg()\==0 /*echo time & bells if any args. */ |
echo= arg()\==0 /*echo time & bells if any args. */ |
||
Line 101: | Line 95: | ||
call delay 60 /*ensure don't re-peel.*/ |
call delay 60 /*ensure don't re-peel.*/ |
||
end /*forever*/ |
end /*forever*/ |
||
halt: /*stick a fork in it, we're done.*/ |
halt: /*stick a fork in it, we're done.*/</lang> |
||
</lang> |
|||
'''output''' when using the input of: <tt> the time is: </tt> |
'''output''' when using the input of: <tt> the time is: </tt> |
||
<pre> |
|||
<pre style="overflow:scroll"> |
|||
the time is: 1:48pm |
the time is: 1:48pm |
||
the time is: 1:49pm |
the time is: 1:49pm |