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
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! :((
Sorry – see the answer to Question 15 (2010). You probably have the same trouble and the same fix should work.
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.
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
Apologies.
Referrers: Question 16 (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?
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: SEQ -- 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.
Referrers: Question 15 (2010)
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 ?
No; `BELL' is a BYTE constant. Please refer to Question 13 (2003).
For Q4 what is the command to make the terminal bleep when any other character is entered apart from those specified?
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:
VAL BYTE BELL IS 7:
It may not work on some terminals -- i.e., those that cannot beep, or those that are configured not to beep.
Referrers: Question 32 (2003)
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.
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.
How do we get the terminal to beep? Is there a character we need to send?
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 ...
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?
You missed it! See the answer to Question 18 (2000).
2000 |
You say that when any other key is pressed for q4, then it should bleep ... How do we do this?
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:
VAL BYTE BELL IS 7:
Referrers: Question 21 (2002) , Question 11 (2001)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |