1. Newby with a Ctrl-C problem

Greetings Euphorians,

Please excuse me if I'm breaking any etiquette rules here ( can't get at
alt.lang.euphoria from behind our firewall and haven't had time to
plough through the archived material ) ...

I'm new to Euphoria - I was so impressed by what I saw when I discovered
the language I have decided to use it on my latest project, however, as
with all languages ( trying to run before I can walk ), I've hit a
problem ...

I *must* be able to trap and handle Ctrl-C within my application -

Using allow_break(TRUE) causes the app. to exit to MS-DOS as soon as
Ctrl-C appears.

Using allow_break(FALSE) prevents the exit to MS-DOS but get_key()
doesn't return anything so I can't tell that Ctrl-C has turned up and
handle it sad

Anyone got any suggestions / solutions ?

Many thanks in anticipation,

John Bown

Origin UK Ltd
323 The Science Park
Milton Road
Cambridge
CB4 4WG
United Kingdom

mailto:john.bown at uk.origin-it.com
http://www.psynet.net/hippy

new topic     » topic index » view message » categorize

2. Re: Newby with a Ctrl-C problem

Welcome to the list-server, and yes I can help you out.
Its from library.doc in your euphoria\doc directory

Ralf

--[check_break]--

Syntax:      include file.e
             i = check_break()

Description: Return the number of times that control-c or control-break have
             been pressed since the last call to check_break(), or since the
             beginning of the program if this is the first call.

Comments:    This is useful after you have called allow_break(0) which
             prevents control-c or control-break from terminating your
             program. You can use check_break() to find out if the user
             has pressed one of these keys. You might then perform some
action
             such as a graceful shutdown of your program.

             Neither control-c nor control-break will be returned as input
             characters when you read the keyboard. You can only detect
             them by calling check_break().

 Example:
              k = get_key()
              if check_break() then
                  temp = graphics_mode(-1)
                  puts(1, "Shutting down...")
                  save_all_user_data()
                  abort(1)
              end if

 See Also: allow_break, get_key

new topic     » goto parent     » topic index » view message » categorize

3. Re: Newby with a Ctrl-C problem

I also have some trouble with CTRL+Break. If i hit in a Euphoria program
launched from the editor in full screen, my computer will reboot without
notice. If  i try to break out of it in a dos box, it'll give me a whole
bunch those notorious 'blue screens'
_________________
When it comes to programming languages, Euphoria is a cut above
matt1278 at juno.com Euphoria programmer
Webbers: <A HREF="mailto:prezsoft at juno.com">prezsoft at juno.com</A>,
president of SoftCo. All virus proggers should die horrible deaths™

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

new topic     » goto parent     » topic index » view message » categorize

4. Re: Newby with a Ctrl-C problem

>I *must* be able to trap and handle Ctrl-C within my application -
>
>Using allow_break(TRUE) causes the app. to exit to MS-DOS as soon as
>Ctrl-C appears.
>
>Using allow_break(FALSE) prevents the exit to MS-DOS but get_key()
>doesn't return anything so I can't tell that Ctrl-C has turned up and
>handle it sad
>
>Anyone got any suggestions / solutions ?

Ralf's idea should work, but it may not work elegantly enough, depending
on the application. (You'll still see a ^C appear in your program.)

Another solution, used by David Cuny in EE, which comes with his TextGUI
toolkit, may work better, but the code is integrated into the toolkit, so
it will have to be extracted. Maybe David could explain further, or I
could dig out the code. (You should get the toolkit anyway, the editor is
more like DOS Edit, so you may feel more comfortable with it.)

The file is KEYS.E, but it has other stuff in it. (It uses some mouse
stuff, and other things from EE in it.) It has a routine in it that gets
the keys and returns CTRL-C safely.

I don't have time right now, but if you want, I can dig out the code for
getting the keys and wrap them up in a .E file, with docs and stuff later
on (Hopefully tonight, with Monday being the latest, depending on how
busy I am). (Or David, you could jump in and get the needed code and give
it to John sooner. blink


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
or call Juno at (800) 654-JUNO [654-5866]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu