Nautical bell: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the output, changed highlighting in the REXX section header.) |
|||
Line 1,197: | Line 1,197: | ||
If any arguments are specified, that text is used as a prefix to the times shown (once a minute). |
If any arguments are specified, that text is used as a prefix to the times shown (once a minute). |
||
<br>Also, the number of bells sounded are shown (if any arguments are specified). |
<br>Also, the number of bells sounded are shown (if any arguments are specified). |
||
<br>If no arguments are specified, no times are shown. |
<br>If no arguments are specified, no times are shown. |
||
Line 1,204: | Line 1,204: | ||
This REXX program makes use of '''delay''' BIF, which delays (sleeps) for a specified amount of seconds. |
This REXX program makes use of '''delay''' BIF, which delays (sleeps) for a specified amount of seconds. |
||
Some REXXes don't have a '''delay''' BIF, so one is included [[DELAY.REX|here]]. |
Some REXXes don't have a '''delay''' BIF, so one is included <big> [[DELAY.REX|here]]. </big> |
||
Also, some REXXes don't have a '''sound''' BIF, which produces sounds via the PC speaker, |
Also, some REXXes don't have a '''sound''' BIF, which produces sounds via the PC speaker, |
||
so one is included [[SOUND.REX|here]]. |
so one is included <big> [[SOUND.REX|here]]. </big> |
||
<lang rexx>/*REXX program sounds "ship's bells" (using PC speaker) when executing (perpetually).*/ |
<lang rexx>/*REXX program sounds "ship's bells" (using PC speaker) when executing (perpetually).*/ |
||
echo= (arg()\==0 |
echo= ( arg()\==0 ) /*echo time and bells if any arguments.*/ |
||
signal on halt /*allow a clean way to stop the program*/ |
signal on halt /*allow a clean way to stop the program*/ |
||
t.1= '00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00' |
t.1= '00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00' |
||
Line 1,215: | Line 1,215: | ||
t.3= '08:30 09:00 09:30 10:00 10:30 11:00 11:30 12:00' |
t.3= '08:30 09:00 09:30 10:00 10:30 11:00 11:30 12:00' |
||
do forever; t=time(); ss=right(t,2); mn=substr(t,4,2) |
do forever; t=time(); ss=right(t, 2); mn=substr(t, 4, 2) /*the current time.*/ |
||
ct=time('C') /*[↓] maybe add leading zero*/ |
ct=time('C') /*[↓] maybe add leading zero to time. */ |
||
hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (with leading zero).*/ |
hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (maybe with a leading zero). */ |
||
if echo then say center(arg(1) ct, 79) /*echo 1st |
if echo then say center(arg(1) ct, 79) /*echo the 1st argument with the time? */ |
||
if ss\==00 & mn\==00 & mn\==30 then do |
if ss\==00 & mn\==00 & mn\==30 then do; call delay 60-ss; iterate |
||
end /* [↑] delay for fraction of a minute.*/ |
|||
/* [↓] the number of bells to peel {$}*/ |
|||
do j=1 for 3 until $\==0; $=wordpos(hhmmc, t.j) |
|||
end /*j*/ |
|||
end /*j*/ |
|||
if $\==0 & echo then say center($ "bells", 79) |
if $\==0 & echo then say center($ "bells", 79) /*echo the number of bells? */ |
||
do k=1 for $; call sound 650,1; call delay 1 + (k//2==0) |
|||
end /*k*/ /*[↑] peel, and then pause for effect.*/ |
|||
call delay 60 |
call delay 60; if rc\==0 then leave /*ensure we don't re─peel. */ |
||
end /*forever*/ |
end /*forever*/ |
||
halt: /*stick a fork in it, we're all done. */</lang> |
halt: /*stick a fork in it, we're all done. */</lang> |
||
{{out|output|text= when using the input of: <big> <tt> the time is: </tt> </big>}} |
|||
<pre> |
<pre> |
||
the time is: 1:48pm |
the time is: 1:48pm |