| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | using ctrlbrk() |
G'Day Paul,
-=> Quoting Paul Wankadia to All <=-
PW> Hi, all. When I change the Ctrl-Break handler using ctrlbrk(), is
PW> there any easy way of just getting the system to IGNORE the Ctrl-Break,
PW> rather than getting the handler to longjmp() back to wherever I was
PW> (which would mean I would need a setjmp() every alternate line <:( I
PW> know it can be done (I am using DOS' EDIT and pressing ^C or Ctrl-Break
PW> does nothing), so what must I do? If I don't capture it at all, ^C or
PW> Ctrl-Break will simply quit out of the program completely -- which I
PW> DON'T want...
Yep, if the handler returns 0 it will quit, make it return 1.
Try something like this..
#include
#include
#include /* for rand() */
#include /* i presume you're using borland ? */
int myhandler( void )
{
asm{cli}; /* not sure if it needs this,the handler seems to restore */
/* it, so presumably it would also clear it, just to be sure */
/* i've left it there */
puts("Quit ? (y/N)");
if(getch() != 'y') return (1); /* nah */
return (0); /* quit */
}
int main( void )
{
int key = 0;
ctrlbrk(myhandler);
while(key != 27)
{
printf("\nNext weeks Tatts nos are, %d,%d,%d,%d,%d,%d",
rand() % 45,rand() % 45,rand() % 45,rand() % 45,rand() % 45,rand() % 45);
while(kbhit())
{
if((key = getch()) == 27) continue;
}
}
return 0;
}
If you win, i'd really like an M3. ;-)
L8r Frank (fadam{at}ozemail.com.au).
___ Blue Wave/DOS v2.21
--- Gash
* Origin: The Software Parlour (3:635/544)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/409 410 413 430 SEEN-BY: 711/808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/544 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.