Hello useRs, Is there a way to write code in R to ring a bell in Windows? Best regards, C. Joseph Lu Department of Statistics National Cheng-Kung University Tainan, Taiwan ROC _______________________________________________________________________
How can we ring a bell in Windows?
7 messages · Lu Joseph, Gabor Grothendieck, Brian Ripley +2 more
Lu Joseph <c_joseph_lu <at> yahoo.com.tw> writes:
:
: Hello useRs,
:
: Is there a way to write code in R
: to ring a bell in Windows?
:
Here are two ways:
cat("\7")
system("sndrec32 /play /close c:/windows/media/ding.wav")
The second way uses Windows Sound Recorder to play the ding.wav file
on my XP system and which may or may exist in the same location on
other versions of Windows.
On Tue, 8 Mar 2005 00:31:07 +0800 (CST), Lu Joseph <c_joseph_lu at yahoo.com.tw> wrote :
Hello useRs, Is there a way to write code in R to ring a bell in Windows?
If you load the tcltk package, then tkbell() will get you a bell on more platforms than just Windows. If you don't want to use tcltk, then you could call the Windows API function MessageBeep from some C code, but I don't think we have a "bell" or "beep" function in the standard R packages. Duncan Murdoch
On Mon, 7 Mar 2005, Duncan Murdoch wrote:
On Tue, 8 Mar 2005 00:31:07 +0800 (CST), Lu Joseph <c_joseph_lu at yahoo.com.tw> wrote :
Hello useRs, Is there a way to write code in R to ring a bell in Windows?
If you load the tcltk package, then tkbell() will get you a bell on more platforms than just Windows. If you don't want to use tcltk, then you could call the Windows API function MessageBeep from some C code, but I don't think we have a "bell" or "beep" function in the standard R packages.
But there is the ANSI "\a": cat("\n") works as expected, on all platforms.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Mon, 7 Mar 2005 18:18:37 +0000 (GMT), Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote :
On Mon, 7 Mar 2005, Duncan Murdoch wrote:
On Tue, 8 Mar 2005 00:31:07 +0800 (CST), Lu Joseph <c_joseph_lu at yahoo.com.tw> wrote :
Hello useRs, Is there a way to write code in R to ring a bell in Windows?
If you load the tcltk package, then tkbell() will get you a bell on more platforms than just Windows. If you don't want to use tcltk, then you could call the Windows API function MessageBeep from some C code, but I don't think we have a "bell" or "beep" function in the standard R packages.
But there is the ANSI "\a": cat("\n") works as expected, on all platforms.
Perhaps we should have a beep() or bell() function, to remind those of us who never knew all the C escapes and wouldn't have guessed that the ancient ASCII control codes still function. I'll put it on my list... Duncan Murdoch
"Duncan" == Duncan Murdoch <murdoch at stats.uwo.ca>
on Mon, 07 Mar 2005 19:32:17 +0000 writes:
Duncan> On Mon, 7 Mar 2005 18:18:37 +0000 (GMT), Prof Brian
Duncan> Ripley <ripley at stats.ox.ac.uk> wrote :
>> On Mon, 7 Mar 2005, Duncan Murdoch wrote:
>>
>>> On Tue, 8 Mar 2005 00:31:07 +0800 (CST), Lu Joseph
>>> <c_joseph_lu at yahoo.com.tw> wrote :
>>>
>>>> Hello useRs,
>>>>
>>>> Is there a way to write code in R to ring a bell in
>>>> Windows?
>>> If you load the tcltk package, then
>>>
>>> tkbell()
>>>
>>> will get you a bell on more platforms than just Windows.
>>> If you don't want to use tcltk, then you could call the
>>> Windows API function MessageBeep from some C code, but I
>>> don't think we have a "bell" or "beep" function in the
>>> standard R packages.
>> But there is the ANSI "\a": cat("\n") works as expected,
>> on all platforms.
{and of course, cat("\a") was meant above}
Duncan> Perhaps we should have a beep() or bell() function,
Duncan> to remind those of us who never knew all the C
Duncan> escapes and wouldn't have guessed that the ancient
Duncan> ASCII control codes still function.
Duncan> I'll put it on my list...
Duncan> Duncan Murdoch
good. Yes that would be a very sensible encapsulation of
functionality.
Note that ASCII control codes don't work on all
kinds of terminals, e.g., they don't work in ESS --- but ESS
could be made to react smartly to a beep() function call.
Martin
Duncan> ______________________________________________
Duncan> R-help at stat.math.ethz.ch mailing list
Duncan> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE
Duncan> do read the posting guide!
Duncan> http://www.R-project.org/posting-guide.html
On Tue, 8 Mar 2005, Martin Maechler wrote:
"Duncan" == Duncan Murdoch <murdoch at stats.uwo.ca>
on Mon, 07 Mar 2005 19:32:17 +0000 writes:
Duncan> On Mon, 7 Mar 2005 18:18:37 +0000 (GMT), Prof Brian Duncan> Ripley <ripley at stats.ox.ac.uk> wrote :
>> On Mon, 7 Mar 2005, Duncan Murdoch wrote: >>
>>> On Tue, 8 Mar 2005 00:31:07 +0800 (CST), Lu Joseph >>> <c_joseph_lu at yahoo.com.tw> wrote : >>>
>>>> Hello useRs, >>>> >>>> Is there a way to write code in R to ring a bell in >>>> Windows?
>>> If you load the tcltk package, then >>> >>> tkbell() >>> >>> will get you a bell on more platforms than just Windows. >>> If you don't want to use tcltk, then you could call the >>> Windows API function MessageBeep from some C code, but I >>> don't think we have a "bell" or "beep" function in the >>> standard R packages.
>> But there is the ANSI "\a": cat("\n") works as expected,
>> on all platforms.
{and of course, cat("\a") was meant above}
Duncan> Perhaps we should have a beep() or bell() function,
Duncan> to remind those of us who never knew all the C
Duncan> escapes and wouldn't have guessed that the ancient
Duncan> ASCII control codes still function.
Well, they are in the current C99 standard, section 5.2.2.
Duncan> I'll put it on my list... Duncan> Duncan Murdoch good. Yes that would be a very sensible encapsulation of functionality. Note that ASCII control codes don't work on all kinds of terminals, e.g., they don't work in ESS --- but ESS could be made to react smartly to a beep() function call.
Why does ESS implement only some of the ANSI/C control codes? That looks like an ESS deficiency. I have never come across any other terminal that did not. These are in the ISO C standard, although the "a" is for "alarm", and that need not be a sound (it says "audible or visible"). So alarm() would be better than beep(). Would it not be better to correct the problem in ESS: there are lots of other ways that \a might be sent to stdout?
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595