kent logo

CO538 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for beep


Question 16 (2010):

Submission reference: IN1912

Hello, my bell isn't working ...

If ALL my code does is output a BELL on the error channel, it works fine! But when I add my processes in, to run AFTER outputting the BELL (SEQ), nothing happens :/

I don't understand! :((

Answer 16:

Sorry – see the answer to Question 15 (2010). You probably have the same trouble and the same fix should work.

Keywords: q4 , bell , beep

Question 15 (2010):

Submission reference: IN1910

In the speed.control process when it comes to outputting BELL nothing seems to happen. I have also changed my code so that whenever I press the '-' key it outputs BELL without doing anything else but this still has no effect (no inverting of colours/screen flash etc). I'm using a Windows machine so in reference to the Question 11 answer this may be different to a Macbook.

Answer 15:

Sorry – this seems to be a bug in the Windows version of the Transterpreter. I finally found a Windows machine and tried the model answer. As you and others have observed, no reaction to BELL, :(. The problem is that characters sent to the error channel are not automatically flushed as per spec (and as we have told you, for example at the end of our answer to Question 11 (2010))!

This is only a problem with the Transterpreter on Windows. On the Mac – and, probably, Linux (I've not tried that yet) – the error channel correctly flushes every character. The kroc run-time also manages the error channel correctly.

We will get this fixed. Meanwhile, wherever you send BELL to the error channel in your solution to q4, follow this with a FLUSH – e.g.

  error ! FLUSH


Keywords: bell , beep , q4

Referrers: Question 16 (2010)

Question 11 (2010):

Submission reference: IN1905

Using the Transterpreter, if you send a BELL down the error channel, is it meant to actually do something, because for me it does nothing or is that just the Transterpreter?

Answer 11:

The BELL character is ASCII code 7 (known as "bell"). On old teletypes, when this was received it actually rang a real bell. On later video terminals, it caused a beep sound. In terminal windows (on modern desktop screens), what happens depends on how your terminal emulator is programmed (sometimes this is user configurable). Many effects are possible:

The terminal window in the Transterpreter JEdit occPlug does the third action above (screen flash) – at least, that's what it does on my Macbook.

Here's a short program (test-bell.occ) that you can cut-and-paste and compile-and-run:


--** Test BELL on screen and error channels.

#INCLUDE "course.module"

--* the main process
-- @param keyboard The standard input channel (stdin, in Unix-speak)
-- @param screen The standard output channel (stdout, in Unix-speak)
-- @param error The standard error channel (stderr, in Unix-speak)
PROC test.bell (CHAN BYTE keyboard?, screen!, error!)

  BYTE ch:
    -- test BELL on screen channel ...
    out.string ("screen: this line will end with a BELL (press a key) ...", 0, screen!)
    screen ! FLUSH
    keyboard ? ch
    screen ! BELL
    screen ! FLUSH     -- the effect of the BELL, if any, happens now!
    out.string ("*c*n", 0, screen!)

    keyboard ? ch      -- wait for keypress.  This is to let the terminal
                       -- emulator complete its reaction to the BELL on
                       -- the screen channel.  Otherwise the terminal
                       -- emulator mixes that up with the following text
                       -- sent to the error channel.  By default, screen
                       -- and error channels are crudely multiplexed to
                       -- the same output device.  From Unix, they can
                       -- be separated.

    -- test BELL on error channel ...
    out.string ("error: this line will end with a BELL (press a key) ...", 0, error!)
    keyboard ? ch
    error ! BELL       -- the effect of the BELL, if any, happens now!
    out.string ("*c*n", 0, error!)



Note: the screen channel needs a FLUSH in order to force out text that doesn't form a completer line (no line-feed character). The error channel, however, flushes every character sent automatically.

Keywords: q4 , bell , beep

Referrers: Question 15 (2010)


Question 32 (2003):

Just a small question, what is the bell character? i.e. the one that makes the terminal bleep? I was told it was BELL, but if thats true do we have to output it one letter at a time ?

Answer 32:

No; `BELL' is a BYTE constant. Please refer to Question 13 (2003).

Keywords: bell , beep

Question 13 (2003):

For Q4 what is the command to make the terminal bleep when any other character is entered apart from those specified?

Answer 13:

Output an ASCII "bell" character:

    out ! BELL

The `BELL' constant is defined in `consts.inc', that is included by q4.occ.

The constant definition is simply:


It may not work on some terminals -- i.e., those that cannot beep, or those that are configured not to beep.

Keywords: q4 , bell , beep

Referrers: Question 32 (2003)


Question 22 (2002):

When we send the bell command to the screen is the internal speaker meant to beep, as mine doesn't. All I get is a symbol of a bell in the lower window. Is this correct? Thanks.

Answer 22:

Unix shell windows (e.g. xterms and xvts) can be set to respond to the bell character (ASCII code 7) in several ways. These include:

That response is not up to your occam program - all it can do is send the character. Setting that response may be possible ... but you'll have to explore the idiosyncracies of your terminal emulator.

Keywords: bell , beep

Question 21 (2002):

How do we get the terminal to beep? Is there a character we need to send?

Answer 21:

See Question 18 (2000). One thing that answer didn't mention, though, is that you probably will also need to output a FLUSH to the screen channel (after sending the BELL). Otherwise, Unix buffers characters sent to the screen until either the buffer gets full or a new-line is output. So, if you want that beep straight away - rather than at the end of the current line of output - don't forget to FLUSH.

Reminder: please look through (and maybe print out) all questions and answers from previous years before re-asking them ...

Keywords: bell , beep


Question 11 (2001):

In Question 4, for the monitor process we are asked to implement the following: `any other character is an error and is processed by bleeping the screen'. I've looked at last years Q+A's on the web but I can't find help on this. Could you give some kind of clue as to how we can produce a bleep from the PC squeaker in occam?

Answer 11:

You missed it! See the answer to Question 18 (2000).

Keywords: q4 , bell , beep


Question 18 (2000):

You say that when any other key is pressed for q4, then it should bleep ... How do we do this?

Answer 18:

If out is the parameter channel (that will be connected to the Unix screen channel), to get a bleep from your terminal:

    out ! BELL

where BELL is the ASCII BEL character, already declared in the (#INCLUDEd) consts.inc file as follows:


Keywords: bell , beep

Referrers: Question 21 (2002) , Question 11 (2001)

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:25 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.