Nautical bell: Difference between revisions

→‎{{header|REXX}}: reinstated original whitespace in the REXX section header, added/changed comments and whitespace, corrected calculation of MN, added better indentation and DO-END groups.
(add OoREXX)
(→‎{{header|REXX}}: reinstated original whitespace in the REXX section header, added/changed comments and whitespace, corrected calculation of MN, added better indentation and DO-END groups.)
Line 842:
 
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>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).
 
This REXX program makes use of <code>DELAY</code>&nbsp; '''delay''' &nbsp; BIF, &nbsp; which delays (sleeps) for a specified amount of seconds (some REXXes don'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 don't have a <code>SOUND</code> BIF, so one is included [[SOUND.REX|here]]).
 
<lang rexx>/*REXX pgm sounds "bells" (using PC speaker) when running (perpetually).*/
Some REXXes don't have a &nbsp; '''delay''' &nbsp; BIF, &nbsp; so one is included [[DELAY.REX|here]].
echo= arg()\==0 /*echo time & bells if any args. */
 
signal on halt /*allow a clean way to stop prog.*/
Also, some REXXes don't have a &nbsp; '''sound''' &nbsp; BIF, &nbsp; which produces sounds via the PC speaker,
&nbsp; so one is included [[SOUND.REX|here]].
<lang rexx>/*REXX pgmprogram sounds "bells" (using PC speaker) when running (perpetually). */
echo= arg()\==0 /*echo time &and bells if any argsarguments. */
signal on halt /*allow a clean way to stop prog.the program*/
t.1 = '00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00'
t.2 = '04:30 05:00 05:30 06:00 06:30 07:00 07:30 08: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=rightsubstr(t,4,2) /*timesthe time.*/
ct=time('C') /*[↓] maybe add leading zero.*/
hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (with leading zero).*/
if echo then say center(arg(1) ct, 79) /*echo arg11st arg with timethe time?*/
if ss\==00 & mn\==00 & mn\==30 then do /*wait for the next minminute ? */
do; call delay 60-ss; iterate; end /* call delay fraction60-ss; of min*/ iterate
end /* [↑] delay minute fraction*/
 
/* [↓] #number 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) /*echo the bells? */
 
do k=1 for $; call sound 650,1; call delay 1 +(k//2==0); end /*k*/
end /*k*/ /*[↑] peel and then pause. */
call delay 60 /*ensure we don't re-peel. */
end /*forever*/
halt: /*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; when using the input of: &nbsp; <tt> the time is: </tt>
<pre>
the time is: 1:48pm