1. beep
--=====================_870457432==_
How does one force a "beep" out of a computer running Euphoria? If it's a
backslash-something code like the ones used for "return" etc. (Reference
Manual, page 15), how is it transmitted -- as two characters?
A related problem: If I increase the tick rate, does the 'time()' counter
indicate seconds or a shorter unit of time?
Details in the attached message.
Wallace B. Riley
--=====================_870457432==_
I'm trying to write a program in Euphoria that will probably run
for several hours if and when I get all the bugs out of it. I
want to include an alarm to alert me that it has finished. I
wrote two similar programs in BASIC some time ago, and they work
well. One of them is a test of the technique, and the other is
incorporated as a subroutine in several BASIC programs. I
attempted twice to duplicate the BASIC test program in Euphoria,
but I ran into a stone wall.
BTW: In David Gay's Beginner's Guide, the ship that crawls across
the screen at the beginning carries a graffito, "BASIC stinks!"
I agree, wholeheartedly; but I've had two computers now that came
with BASIC bundled when I bought them; so I used it. Most of my
programs worked, and speed was usually not important, so I used
what I had rather than rush out and buy something else.
In the BASIC programs I print the hex character #07 on the
screen. In the original ASCII, which is now probably obsolete or
at least obsolescent, #07 is the code that sounds a beep. In
ANSI code, the newer version of ASCII (and sometimes called ASCII
-- erroneously, I suspect, because it is too easily confused with
the former code), #07 is a bullet of some kind, the sort of thing
that one might use to emphasize paragraphs. ANSI apparently has
no code for a beep; nor does it have one for carriage return or
line feed (these used to be #0D and #0A respectively, but those
codes now represent more bullets). Nevertheless, returns are
still recognized.
I wrote a program in Euphoria that more or less duplicates the
old BASIC program, using puts(1,#07), but it only silently
displays bullets on the screen.
In a second Euphoria program, I substituted the commands
sound(1000) and sound(0) in place of puts(1,#07). It works, but
the beeps are rather languid, because they are 1 second in
duration and have 1-second intervals between them. There doesn't
seem to be any way to generate peppier beeps than that, unless
the secret is in the tick rate.
--=====================_870457432==_--
2. Re: beep
This should produce a beep from the speaker.
---- code begins ----
include machine.e
procedure beep()
sequence regs
regs = repeat(0, 10)
-- Write character in Teletype Mode
-- video function E
-- character 7 (bell, generates a 1/2 second beep using timer 2)
regs[REG_AX] = #0E07
regs = dos_interrupt(#10, regs)
end procedure
beep()
---- code ends ----
Unfortunately I am unable to test this, my own speaker is busted.
I Hope this helps, or even works!
--
_____ _____ _____
________ /\ \ /\ \ /\ \
/ \ \ / \____\ / \____\ / \____\
/ _ \____\ / / ___/_ / /____/ / / ___/_
/ / \ |____|/ / /\____\ / \ \ / / /\____\
\ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_
\ /____/ \ / /\ \\/\ \ \ \ / /\ \
\ \ \ \ \/ \____\ \ \ \ \ \/ \____\
\ \ \ \ / / \ \____\ \ / /
\ \____\ \ / / \ / / \ / /
\ / / \ / / \/____/ \ / /
\/____/ \/____/ \/____/
3. beep
Well, I guess I don't understand the issue of windows(xp) beeping. I've
spend several days trying to remove the annoyance and have failed. The
escape, enter, and tab keys beep eventhough I've placed returnValue(-1).
Perhaps I've put in at the wrong place in the code. Interesting is
that if instead of using 'keyDown' I use 'keyPress' the beeping stops
but then I have the 'q' having the same keyCode as 'F2'problem. Here's a
snip of the code
If anyone has a hint of where to look please clue me in...
BTW, I'm using win32 59.1
--------------------------------------------------------------------------
procedure keyDownProcess(integer self, integer processId, sequence arg)
integer keyCode, shift
keyCode = arg[1]
shift = arg[2]
if find (keyCode, {esc, tab, downArrow, upArrow, cr, f1,
f2, f3 , f4, f5, f6, f7, f8, f9, f10}) then
SpecialKeyProcess(self, processId, {keyCode, shift})
returnValue(-1)
else
NormalKeyProcess(self, processId, {keyCode, shift})
end if
end procedure
-- setHandler(Screen, w32HKeyPress, routine_id("keyPressProcess"))
setHandler(Screen, w32HKeyDown, routine_id("keyDownProcess"))
-------------------------------------------------------------------------------------
WinMain(Main,Normal)
4. Re: beep
In fact if I do nothing but 'returnValue(-1)' in keyDownProcess it
beeps. I think something is wrong with 59.1....
How I'm using this is... the cursor is setting in an EditText field and
I want to hit escape to back out, or hit tab to go to the next field, or
hit the Enter to go to the next field... It works that way, but with the
annoying beep.
George Walters wrote:
>
> Well, I guess I don't understand the issue of windows(xp) beeping. I've
> spend several days trying to remove the annoyance and have failed. The
> escape, enter, and tab keys beep eventhough I've placed returnValue(-1).
> Perhaps I've put in at the wrong place in the code. Interesting is that
> if instead of using 'keyDown' I use 'keyPress' the beeping stops but
> then I have the 'q' having the same keyCode as 'F2'problem. Here's a
> snip of the code
>
> If anyone has a hint of where to look please clue me in...
> BTW, I'm using win32 59.1
>
> }}}
<eucode>
> --------------------------------------------------------------------------
> procedure keyDownProcess(integer self, integer processId, sequence arg)
>
returnValue(-1)
return
> integer keyCode, shift
>
>
> keyCode = arg[1]
> shift = arg[2]
>
> if find (keyCode, {esc, tab, downArrow, upArrow, cr, f1, f2, f3
> , f4, f5, f6, f7, f8, f9, f10}) then
>
> SpecialKeyProcess(self, processId, {keyCode, shift})
> returnValue(-1)
>
> else
>
> NormalKeyProcess(self, processId, {keyCode, shift})
>
> end if
>
> end procedure
>
>
> -- setHandler(Screen, w32HKeyPress, routine_id("keyPressProcess"))
> setHandler(Screen, w32HKeyDown, routine_id("keyDownProcess"))
>
> -------------------------------------------------------------------------------------
>
>
> WinMain(Main,Normal)
> </eucode>
{{{
>
>
>
>
5. Re: beep
George Walters wrote:
>
> Well, I guess I don't understand the issue of windows(xp) beeping. I've
> spend several days trying to remove the annoyance and have failed. The
> escape, enter, and tab keys beep eventhough I've placed returnValue(-1).
> Perhaps I've put in at the wrong place in the code. Interesting is
> that if instead of using 'keyDown' I use 'keyPress' the beeping stops
> but then I have the 'q' having the same keyCode as 'F2'problem. Here's a
> snip of the code
>
> If anyone has a hint of where to look please clue me in...
> BTW, I'm using win32 59.1
>
> }}}
<eucode>
> --------------------------------------------------------------------------
> procedure keyDownProcess(integer self, integer processId, sequence arg)
>
> integer keyCode, shift
>
>
> keyCode = arg[1]
> shift = arg[2]
>
> if find (keyCode, {esc, tab, downArrow, upArrow, cr, f1,
> f2, f3 , f4, f5, f6, f7, f8, f9, f10}) then
>
> SpecialKeyProcess(self, processId, {keyCode, shift})
> returnValue(-1)
>
> else
>
> NormalKeyProcess(self, processId, {keyCode, shift})
>
> end if
>
> end procedure
>
>
> -- setHandler(Screen, w32HKeyPress, routine_id("keyPressProcess"))
> setHandler(Screen, w32HKeyDown, routine_id("keyDownProcess"))
>
> -------------------------------------------------------------------------------------
> WinMain(Main,Normal)
> </eucode>
{{{
I think the problem is because ESC, TAB, CR are also KeyPress events and
when you throw away the keydown (returnValue(-1)) Windows gets confused
because it gets a keyup event with out the matching keydown so it can't
assume its a valid keypress so it beeps an alert.
Why are you throwing away these keys? You don't have to get rid of the
function and arrow keys because most controls don't use them anyhow.
Its easier to get rid of the other keys during a keypress anyway.
I can't seem to get the beeps on my system but I'll try some different
tests.
--
Derek Parnell
Melbourne, Australia
6. Re: beep
George Walters wrote:
>
> In fact if I do nothing but 'returnValue(-1)' in keyDownProcess it
> beeps. I think something is wrong with 59.1....
>
> How I'm using this is... the cursor is setting in an EditText field and
> I want to hit escape to back out, or hit tab to go to the next field, or
> hit the Enter to go to the next field... It works that way, but with the
> annoying beep.
>
>
Okay... TAB and ENTER already work that way (Version 0.60+). Trap these
keys during a keypress, not keydown.
--
Derek Parnell
Melbourne, Australia
7. Re: beep
Derek, unfortunately I can't use 60.x at this point. It breaks all my
code. I've been using Groups only to dress up the screen (box's with
nice title), but I put all the controls in the underlying window, so all
the controls are not visible. I would like to keep up with the
development if I could solve this problem easily.
Derek Parnell wrote:
>
> Okay... TAB and ENTER already work that way (Version 0.60+). Trap these
> keys during a keypress, not keydown.
>
I also use down arrow and up arrow the same way.
george
8. Re: beep
On 2 Oct 2004, at 2:26, Derek Parnell wrote:
>
>
> posted by: Derek Parnell <ddparnell at bigpond.com>
>
> George Walters wrote:
> >
> > In fact if I do nothing but 'returnValue(-1)' in keyDownProcess it
> > beeps. I think something is wrong with 59.1....
> >
> > How I'm using this is... the cursor is setting in an EditText field and
> > I want to hit escape to back out, or hit tab to go to the next field, or hit
> > the Enter to go to the next field... It works that way, but with the
> > annoying
> > beep.
> >
> >
> Okay... TAB and ENTER already work that way (Version 0.60+). Trap these
> keys during a keypress, not keydown.
On every computer i have built since 1990 or so, i have trapped the wires
going to the speaker. This has worked (so far) with assorted msdos-s and
windows95.
Kat
9. Re: beep
- Posted by Derek Parnell <ddparnell at bigpond.com>
Oct 02, 2004
-
Last edited Oct 03, 2004
George Walters wrote:
>
> Well, I guess I don't understand the issue of windows(xp) beeping. I've
> spend several days trying to remove the annoyance and have failed. The
> escape, enter, and tab keys beep eventhough I've placed returnValue(-1).
> Perhaps I've put in at the wrong place in the code. Interesting is
> that if instead of using 'keyDown' I use 'keyPress' the beeping stops
> but then I have the 'q' having the same keyCode as 'F2'problem. Here's a
> snip of the code
>
> If anyone has a hint of where to look please clue me in...
> BTW, I'm using win32 59.1
Since you are using this old version, you will need to patch it.
In the routine fDoKeys() locate the line ....
if iMsg = WM_CHAR and sequence(lUserReturn) then
and replace it with ...
if sequence(lUserReturn) then
Here is the code that I used to test it...
include win32lib.ew
without warning
constant Main = create(Window, "key test", 0, 0, 0, 360, 190, 0)
constant EB = create(EditText, "", Main, 5, 5, 340, 30, 0)
constant SB = create(StatusBar, "", Main, 0, 0, 0, 0, 0)
procedure SpecialKeyProcess(integer self, integer processId, sequence arg)
setText(SB, sprintf("SPECIAL %d %d %d", {processId, arg[1], arg[2]}))
end procedure
procedure NormalKeyProcess(integer self, integer processId, sequence arg)
setText(SB, sprintf("NORMAL %d %d %d", {processId, arg[1], arg[2]}))
end procedure
--------------------------------------------------------------------------
procedure keyDownProcess(integer self, integer processId, sequence arg)
integer keyCode, shift
keyCode = arg[1]
shift = arg[2]
if find (keyCode, { VK_DOWN, VK_UP, VK_F1, VK_F2}) then
SpecialKeyProcess(self, processId, {keyCode, shift})
returnValue(-1)
else
NormalKeyProcess(self, processId, {keyCode, shift})
end if
end procedure
--------------------------------------------------------------------------
procedure keyPressProcess(integer self, integer processId, sequence arg)
integer keyCode, shift
keyCode = arg[1]
shift = arg[2]
if find (keyCode, {VK_ESCAPE, VK_TAB,VK_RETURN }) then
SpecialKeyProcess(self, processId, {keyCode, shift})
returnValue(-1)
else
NormalKeyProcess(self, processId, {keyCode, shift})
end if
end procedure
setText(Main, sprintf("Win32Lib version %d.%d Patch#%d, %s",
{Win32LibVersion[1],
Win32LibVersion[2],
Win32LibVersion[3],
Win32LibVersion[4]
}))
setHandler(Screen, w32HKeyPress, routine_id("keyPressProcess"))
setHandler(Screen, w32HKeyDown, routine_id("keyDownProcess"))
-------------------------------------------------------------------------------------
WinMain(Main,Normal)
But back to the reason you are using the old version of win32lib. Are
you saying that you have placed a Group control on the window and
placed other control 'underneath' the group control and that they
are visible when you do that? If so, that is NOT correct behaviour and
I'm glad that I fixed that. The idea for Group control is to make this
the parent of controls you wish to see inside it. If you just wanted
to draw a box with title aound them, it would have been better to draw
a box around them and place a title on it (via the paint event).
--
Derek Parnell
Melbourne, Australia
10. Re: beep
Thanks Derek, that worked quite well in getting rid of the beep. I did
find however that it broke the space bar toggling check boxes. Would
that be expected with your change? Or did I make a mistake.
george
Derek Parnell wrote:
> Since you are using this old version, you will need to patch it.
> In the routine fDoKeys() locate the line ....
>
> if iMsg = WM_CHAR and sequence(lUserReturn) then
>
> and replace it with ...
>
> if sequence(lUserReturn) then
>
11. Re: beep
George Walters wrote:
>
> Thanks Derek, that worked quite well in getting rid of the beep. I did
> find however that it broke the space bar toggling check boxes. Would
> that be expected with your change? Or did I make a mistake.
Sorry, but I suspect a problem with your code as it works fine here.
You don't trap space chars do you? If you can you send me the *smallest*
example code that still demonstrates this behaviour, I'll look into it.
--
Derek Parnell
Melbourne, Australia