Nautical bell: Difference between revisions
Content added Content deleted
(Nautical bell in FreeBASIC) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 22: | Line 22: | ||
This version uses local time and speaks the bell rings using OS X's built-in speech synthesizer. |
This version uses local time and speaks the bell rings using OS X's built-in speech synthesizer. |
||
< |
<syntaxhighlight lang="applescript">repeat |
||
set {hours:h, minutes:m} to (current date) |
set {hours:h, minutes:m} to (current date) |
||
if {0, 30} contains m then |
if {0, 30} contains m then |
||
Line 36: | Line 36: | ||
end if |
end if |
||
delay 60 |
delay 60 |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
==='idle' handler=== |
==='idle' handler=== |
||
Line 42: | Line 42: | ||
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. |
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. |
||
< |
<syntaxhighlight lang="applescript">use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later |
||
use framework "Foundation" |
use framework "Foundation" |
||
use scripting additions |
use scripting additions |
||
Line 85: | Line 85: | ||
-- Request another call in half an hour's time, less however long the above took. |
-- Request another call in half an hour's time, less however long the above took. |
||
return halfHour - (time of (current date)) mod halfHour |
return halfHour - (time of (current date)) mod halfHour |
||
end idle</ |
end idle</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">NauticalBell(hh, mm){ |
||
Hr := 0, min := 30, Bells := [], pattern := [] |
Hr := 0, min := 30, Bells := [], pattern := [] |
||
Loop 8 ; genrate 8 patterns |
Loop 8 ; genrate 8 patterns |
||
Line 107: | Line 107: | ||
Bells[00 ":" 00] := Bells[24 ":" 00] , numBells := Bells[hh ":" mm] |
Bells[00 ":" 00] := Bells[24 ":" 00] , numBells := Bells[hh ":" mm] |
||
return {"bells": numBells, "pattern": Pattern[numBells]} |
return {"bells": numBells, "pattern": Pattern[numBells]} |
||
}</ |
}</syntaxhighlight> |
||
Example:< |
Example:<syntaxhighlight lang="autohotkey">res := "" |
||
loop, 24 |
loop, 24 |
||
{ |
{ |
||
Line 120: | Line 120: | ||
} |
} |
||
MsgBox, 262144, , % "Time`tBells`tPattern`n" res |
MsgBox, 262144, , % "Time`tBells`tPattern`n" res |
||
return</ |
return</syntaxhighlight> |
||
Outputs:<pre>Time Bells Pattern |
Outputs:<pre>Time Bells Pattern |
||
00:00 8 ** ** ** ** |
00:00 8 ** ** ** ** |
||
Line 174: | Line 174: | ||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang="awk"> |
|||
<lang AWK> |
|||
# syntax: GAWK -f NAUTICAL_BELL.AWK |
# syntax: GAWK -f NAUTICAL_BELL.AWK |
||
BEGIN { |
BEGIN { |
||
Line 226: | Line 226: | ||
return(new_str) |
return(new_str) |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
<p>Output:</p> |
<p>Output:</p> |
||
<pre> |
<pre> |
||
Line 283: | Line 283: | ||
Implementation corrected, sounds the system bell as per nautical standards, sounds bell as per local system time. |
Implementation corrected, sounds the system bell as per nautical standards, sounds bell as per local system time. |
||
<syntaxhighlight lang="c"> |
|||
<lang C> |
|||
#include<unistd.h> |
#include<unistd.h> |
||
#include<stdio.h> |
#include<stdio.h> |
||
Line 338: | Line 338: | ||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
This version uses local time. |
This version uses local time. |
||
< |
<syntaxhighlight lang="cpp"> |
||
#include <iostream> |
#include <iostream> |
||
#include <string> |
#include <string> |
||
Line 412: | Line 412: | ||
} |
} |
||
//-------------------------------------------------------------------------------------------------- |
//-------------------------------------------------------------------------------------------------- |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 467: | Line 467: | ||
=={{header|D}}== |
=={{header|D}}== |
||
This code uses local time instead of Greenwich Mean Time. |
This code uses local time instead of Greenwich Mean Time. |
||
< |
<syntaxhighlight lang="d">import std.stdio, core.thread, std.datetime; |
||
class NauticalBell : Thread { |
class NauticalBell : Thread { |
||
Line 516: | Line 516: | ||
writeln(e.msg); |
writeln(e.msg); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
This output is from an actual test run. |
This output is from an actual test run. |
||
<pre> |
<pre> |
||
Line 568: | Line 568: | ||
09:00:00 : 2 bells</pre> |
09:00:00 : 2 bells</pre> |
||
< |
<syntaxhighlight lang="freebasic">Dim As Byte m = 0 |
||
For n As Byte = 0 To 23 |
For n As Byte = 0 To 23 |
||
If n = 23 Then |
If n = 23 Then |
||
Line 584: | Line 584: | ||
End If |
End If |
||
Next n |
Next n |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
Provided your terminal bell is enabled, this should beep an appropriate number of times before displaying its output. It uses local time. |
Provided your terminal bell is enabled, this should beep an appropriate number of times before displaying its output. It uses local time. |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 634: | Line 634: | ||
time.Sleep(1 * time.Second) |
time.Sleep(1 * time.Second) |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 649: | Line 649: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
This solution first creates a general way of scheduling tasks on a time interval, and then schedules a "ringing" task. If used in a terminal it will also produce noise. Local time is used. |
This solution first creates a general way of scheduling tasks on a time interval, and then schedules a "ringing" task. If used in a terminal it will also produce noise. Local time is used. |
||
< |
<syntaxhighlight lang="haskell"> |
||
import Control.Concurrent |
import Control.Concurrent |
||
import Control.Monad |
import Control.Monad |
||
Line 728: | Line 728: | ||
bellRinger = doWithScheduler (onInterval (30*60)) ringBells |
bellRinger = doWithScheduler (onInterval (30*60)) ringBells |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 742: | Line 742: | ||
{{trans|Raku}} |
{{trans|Raku}} |
||
'''Solution''':< |
'''Solution''':<syntaxhighlight lang="j">require 'strings printf' |
||
WATCH =: <;._1 ' Middle Morning Forenoon Afternoon Dog First' |
WATCH =: <;._1 ' Middle Morning Forenoon Afternoon Dog First' |
||
Line 802: | Line 802: | ||
end. |
end. |
||
y |
y |
||
)</ |
)</syntaxhighlight> |
||
'''Examples''': Invoke <tt>shipsWatch 0</tt>; the output is identical to Raku's. |
'''Examples''': Invoke <tt>shipsWatch 0</tt>; the output is identical to Raku's. |
||
Line 811: | Line 811: | ||
This code uses UTC time. |
This code uses UTC time. |
||
{{trans|D}} |
{{trans|D}} |
||
< |
<syntaxhighlight lang="java">import java.text.DateFormat; |
||
import java.text.SimpleDateFormat; |
import java.text.SimpleDateFormat; |
||
import java.util.TimeZone; |
import java.util.TimeZone; |
||
Line 860: | Line 860: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
Sample output: |
Sample output: |
||
Line 871: | Line 871: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia">using Dates |
||
""" |
""" |
||
Line 912: | Line 912: | ||
nauticalbelltask() |
nauticalbelltask() |
||
</ |
</syntaxhighlight> {{output}} <pre> |
||
Nautical bell task starting -- next bell in 1201.726 seconds. |
Nautical bell task starting -- next bell in 1201.726 seconds. |
||
Nautical bell gong strikes 2 2 2 |
Nautical bell gong strikes 2 2 2 |
||
Line 937: | Line 937: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
< |
<syntaxhighlight lang="scala">// version 1.1.3 |
||
import java.text.DateFormat |
import java.text.DateFormat |
||
Line 990: | Line 990: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
Sample output: |
Sample output: |
||
Line 1,003: | Line 1,003: | ||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
Works on version 11.2 ARM, a bug prevents this from working on version 11.3 Win64. |
Works on version 11.2 ARM, a bug prevents this from working on version 11.3 Win64. |
||
< |
<syntaxhighlight lang="mathematica">LocalSubmit[ScheduledTask[ |
||
EmitSound[Sound[Table[{ |
EmitSound[Sound[Table[{ |
||
SoundNote["C",750/1000,"TubularBells"],SoundNote[None,500/1000,"TubularBells"] |
SoundNote["C",750/1000,"TubularBells"],SoundNote[None,500/1000,"TubularBells"] |
||
},Mod[Round[Total[DateList[][[{4,5}]]{2,1/30}]],8,1]]]] |
},Mod[Round[Total[DateList[][[{4,5}]]{2,1/30}]],8,1]]]] |
||
,DateObject[{_,_,_,_,_,30|0}]]]</ |
,DateObject[{_,_,_,_,_,30|0}]]]</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Phix}} |
{{trans|Phix}} |
||
Using UTC time but the program can easily be adapted to use local time (replace <code>getTime().utc()</code> with <code>getTime().local()</code> or <code>now()</code>). |
Using UTC time but the program can easily be adapted to use local time (replace <code>getTime().utc()</code> with <code>getTime().local()</code> or <code>now()</code>). |
||
< |
<syntaxhighlight lang="nim">import os, strformat, times |
||
const |
const |
||
Line 1,051: | Line 1,051: | ||
if m == 0: |
if m == 0: |
||
nb(d.hour, d.minute) |
nb(d.hour, d.minute) |
||
sleep((1800 - m) * 1000) # In milliseconds.</ |
sleep((1800 - m) * 1000) # In milliseconds.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,058: | Line 1,058: | ||
=={{header|OoRexx}}== |
=={{header|OoRexx}}== |
||
{{trans|REXX}} |
{{trans|REXX}} |
||
< |
<syntaxhighlight lang="oorexx">/*REXX pgm beep's "bells" (using PC speaker) when running (perpetually).*/ |
||
Parse Arg msg |
Parse Arg msg |
||
If msg='?' Then Do |
If msg='?' Then Do |
||
Line 1,103: | Line 1,103: | ||
Return res |
Return res |
||
halt:</ |
halt:</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
< |
<syntaxhighlight lang="perl">use utf8; |
||
binmode STDOUT, ":utf8"; |
binmode STDOUT, ":utf8"; |
||
use DateTime; |
use DateTime; |
||
Line 1,150: | Line 1,150: | ||
} |
} |
||
print "\n"; |
print "\n"; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre style="height:35ex">00:30 Middle watch, One Bell Gone: ♪ |
<pre style="height:35ex">00:30 Middle watch, One Bell Gone: ♪ |
||
Line 1,207: | Line 1,207: | ||
instead of <code>date(DT_GMT)</code>.<br> |
instead of <code>date(DT_GMT)</code>.<br> |
||
Uses a full-length sleep of up to 1800 seconds (half an hour), as it should. |
Uses a full-length sleep of up to 1800 seconds (half an hour), as it should. |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">watches</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"First"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Middle"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Morning"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Forenoon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Afternoon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Last dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First"</span><span style="color: #0000FF;">},</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">watches</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"First"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Middle"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Morning"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Forenoon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Afternoon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Last dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"First"</span><span style="color: #0000FF;">},</span> |
||
Line 1,248: | Line 1,248: | ||
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,306: | Line 1,306: | ||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
This program sounds the bell as well as displaying "gong" an appropriate number of times. It operates on local time. |
This program sounds the bell as well as displaying "gong" an appropriate number of times. It operates on local time. |
||
<syntaxhighlight lang="pl/i"> |
|||
<lang PL/I> |
|||
nautical: procedure options (main); /* 29 October 2013 */ |
nautical: procedure options (main); /* 29 October 2013 */ |
||
declare (hour, t, i) fixed binary; |
declare (hour, t, i) fixed binary; |
||
Line 1,321: | Line 1,321: | ||
end; |
end; |
||
end nautical; |
end nautical; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
<syntaxhighlight lang="powershell"> |
|||
<lang PowerShell> |
|||
function Get-Bell |
function Get-Bell |
||
{ |
{ |
||
Line 1,404: | Line 1,404: | ||
Get-Bell -Hour $_ -Minute 30 |
Get-Bell -Hour $_ -Minute 30 |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 1,438: | Line 1,438: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
As well as typing output to stdout, this program plays a sound for each bell as the ␇ characters are printed (The spaces between the ␇ characters are mirrored as varying delays between each ring). |
As well as typing output to stdout, this program plays a sound for each bell as the ␇ characters are printed (The spaces between the ␇ characters are mirrored as varying delays between each ring). |
||
< |
<syntaxhighlight lang="python">import time, calendar, sched, winsound |
||
duration = 750 # Bell duration in ms |
duration = 750 # Bell duration in ms |
||
Line 1,500: | Line 1,500: | ||
if __name__ == '__main__': |
if __name__ == '__main__': |
||
ships_bell()</ |
ships_bell()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>00:00, First watch 8 bells ␇ ␇ ␇ ␇ ␇ ␇ ␇ ␇ |
<pre>00:00, First watch 8 bells ␇ ␇ ␇ ␇ ␇ ␇ ␇ ␇ |
||
Line 1,556: | Line 1,556: | ||
that displays \a by playing the system bell, it will play the system bell. |
that displays \a by playing the system bell, it will play the system bell. |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(require racket/date) |
(require racket/date) |
||
Line 1,613: | Line 1,613: | ||
(wait-til s) |
(wait-til s) |
||
(format-and-print hours (add1 bells)))) |
(format-and-print hours (add1 bells)))) |
||
</syntaxhighlight> |
|||
</lang> |
|||
This might produce the following output: |
This might produce the following output: |
||
Line 1,634: | Line 1,634: | ||
Raku uses [[wp:Coordinated_Universal_Time|UTC]] (GMT) time internally and by default. This will display the current UTC time and on the half hour, display a graphical representation of the bell. If run in a terminal with the system bell enabled, will also chime the system alarm bell. |
Raku uses [[wp:Coordinated_Universal_Time|UTC]] (GMT) time internally and by default. This will display the current UTC time and on the half hour, display a graphical representation of the bell. If run in a terminal with the system bell enabled, will also chime the system alarm bell. |
||
<lang |
<syntaxhighlight lang="raku" line>my @watch = <Middle Morning Forenoon Afternoon Dog First>; |
||
my @ordinal = <One Two Three Four Five Six Seven Eight>; |
my @ordinal = <One Two Three Four Five Six Seven Eight>; |
||
Line 1,674: | Line 1,674: | ||
print "\n"; |
print "\n"; |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>00:00 First watch, Eight Bells Gone: ♫ ♫ ♫ ♫ |
<pre>00:00 First watch, Eight Bells Gone: ♫ ♫ ♫ ♫ |
||
Line 1,740: | Line 1,740: | ||
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 <big> [[SOUND.REX|here]]. </big> |
so one is included <big> [[SOUND.REX|here]]. </big> |
||
< |
<syntaxhighlight lang="rexx">/*REXX program sounds "ship's bells" (using PC speaker) when executing (perpetually).*/ |
||
echo= ( arg()\==0 ) /*echo time and bells if any arguments.*/ |
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*/ |
||
Line 1,763: | Line 1,763: | ||
call delay 60; if rc\==0 then leave /*ensure we don't re─peel. */ |
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. */</ |
halt: /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
{{out|output|text= when using the input of: <big> <tt> the time is: </tt> </big>}} |
{{out|output|text= when using the input of: <big> <tt> the time is: </tt> </big>}} |
||
<pre> |
<pre> |
||
Line 1,788: | Line 1,788: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
# Project : Nautical bell |
# Project : Nautical bell |
||
Line 1,809: | Line 1,809: | ||
ok |
ok |
||
next |
next |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 1,863: | Line 1,863: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">watches = [ "First", "Middle", "Morning", "Forenoon", "Afternoon", "First dog", "Last dog", "First" ] |
||
watch_ends = [ "00:00", "04:00", "08:00", "12:00", "16:00", "18:00", "20:00", "23:59" ] |
watch_ends = [ "00:00", "04:00", "08:00", "12:00", "16:00", "18:00", "20:00", "23:59" ] |
||
words = ["One","Two","Three","Four","Five","Six","Seven","Eight"] |
words = ["One","Two","Three","Four","Five","Six","Seven","Eight"] |
||
Line 1,885: | Line 1,885: | ||
end |
end |
||
sleep 1 |
sleep 1 |
||
end</ |
end</syntaxhighlight> |
||
{{out|Sample output}} |
{{out|Sample output}} |
||
Line 1,941: | Line 1,941: | ||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
include "time.s7i"; |
include "time.s7i"; |
||
include "duration.s7i"; |
include "duration.s7i"; |
||
Line 1,977: | Line 1,977: | ||
flush(OUT); |
flush(OUT); |
||
end while; |
end while; |
||
end func;</ |
end func;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,033: | Line 2,033: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
This code was originally based on the [[#Raku|Raku]] version, but with numerous adaptations, alterations and (some) corrections. |
This code was originally based on the [[#Raku|Raku]] version, but with numerous adaptations, alterations and (some) corrections. |
||
< |
<syntaxhighlight lang="tcl"># More sophisticated versions are possible, such as playing a bell sample |
||
# using the Snack library. |
# using the Snack library. |
||
proc ringTheBell {} { |
proc ringTheBell {} { |
||
Line 2,107: | Line 2,107: | ||
fconfigure stdout -buffering none |
fconfigure stdout -buffering none |
||
every 1000 nauticalBell |
every 1000 nauticalBell |
||
vwait forever; # Only needed if not running an event loop otherwise</ |
vwait forever; # Only needed if not running an event loop otherwise</syntaxhighlight> |
||
{{out|Sample output}} |
{{out|Sample output}} |
||
<pre> |
<pre> |
||
Line 2,125: | Line 2,125: | ||
On my system (Ubuntu 20.04), the bell only rings once no matter how many \a's are concatenated togther, though it may be different on other systems. |
On my system (Ubuntu 20.04), the bell only rings once no matter how many \a's are concatenated togther, though it may be different on other systems. |
||
< |
<syntaxhighlight lang="ecmascript">import "os" for Process |
||
import "timer" for Timer |
import "timer" for Timer |
||
import "/date" for Date |
import "/date" for Date |
||
Line 2,166: | Line 2,166: | ||
Timer.sleep(1000) |
Timer.sleep(1000) |
||
now = now.addSeconds(1) |
now = now.addSeconds(1) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |