Java Question: Beep? (in Off-topic)


SNK3R March 2 2006 7:19 PM EST

I was looking at Java examples the other day and I came across one code that displays the date/time and beeps. I thought it was pretty cool since I didn't know one could do that, but hey, I'm only in Intro. to Java. :) Anyway, I started messing around with the code to see what was causing the beep, and I finally figured out (easily) that is was the \007. I started decreasing the number and increasing the number to see what results I would get and when I decreased the number I received smiley faces, diamonds, clubs, etc. When I increased the number all I received were blanks with the number included.

In any case, I was wondering what the programmer calls these things and where I could possibly find a list of items that describes what each thing does. In case you need to see the coding, which you probably don't if you're Java-skilled, the following is the coding:

import java.util.*;
public class BeepDate
{
    public static void main(String[] args)
    {
        System.out.println(new Date() + "\007");
    }
}

[T]Vestax March 2 2006 7:34 PM EST

the \007 is nothing more then the ASCII code for a character. This character just so happens to actually be a beep from your Computer's hardware... not the sound card and not coming through your speakers, but from the motherboard itself.

These should be the same beeps that you would here if you have a bad memory chip, or something else that would be picked up as a hardware error by your Bios. In short, that thing is very very old. As for the list of what each number would display/sound, just google around for ASCII code.

Stephen March 2 2006 7:36 PM EST

"\007" = \a I think

Karmic Mishap [Soup Ream] March 2 2006 7:36 PM EST

Those are ASCII escape codes, and you can find a full list of them at Lookuptables.com

Stephen March 2 2006 7:37 PM EST

007 BEL (Bell)

[T]Vestax March 2 2006 7:38 PM EST

P.S. Only the \007 will make a sound. All other numbers will display something (and sometimes nothing) to the screen This includes things like the carriage return and new line characters.

SNK3R March 2 2006 7:40 PM EST

Sweet, thanks, guys! Now I can beep away and annoy my professor when I turn in my labs. Hehe... ;)

[T]Vestax March 2 2006 7:44 PM EST

My god, what have we unleashed upon this fragile world?

PoisoN March 2 2006 7:49 PM EST

Unicode ;-)

Maelstrom March 2 2006 8:14 PM EST

I believe Java also has a method that'll produce a beep - System.beep() - I think.

If have have any troubles/questions about that course, feel free to ask me. I have useless academic-style beginner's Java mastered. Taught a first-year course in it last year, and probably will again this summer...

SNK3R March 2 2006 8:16 PM EST

Actually, while looking at the bottom left box in TextPad, I noticed it had a section of 'Control Characters.' So all I really need to do is right click > insert where I want the beep and it'll do it for me without having to remember \007. ;)

SNK3R March 2 2006 8:16 PM EST

Oh, and thanks for the offer, Mael. :)

maulaxe March 2 2006 9:10 PM EST

Textpad rocks my world.

Its a small world, admittedly, but still.

smallpau1 - Go Blues [Lower My Fees] March 2 2006 9:25 PM EST

im also in intro to Java, and im lost as all crap... This semester is my prof's first time teaching and you can tell.....

Maelstrom March 2 2006 11:05 PM EST

Have any specific problems? What text do you use?

[T]Vestax March 2 2006 11:09 PM EST

I've done Java tutoring before. Aced the class when I took it. If you have a question I might be able to answer it as well.

smallpau1 - Go Blues [Lower My Fees] March 3 2006 2:39 AM EST

we use eclipse, but right now we just took a test, so no questions just yet.

Maelstrom March 3 2006 8:59 AM EST

I meant what textbook, not text editor. I personally don't like Eclipse, but my friends are all trying to get me to use it. It's all Emacs for me :)
This thread is closed to new posts. However, you are welcome to reference it from a new thread; link this with the html <a href="/bboard/q-and-a-fetch-msg.tcl?msg_id=001jDL&msg_id=001jDL">Java Question: Beep?</a>