bruceb@amiga.UUCP (Bruce Barrett) (03/01/86)
Hi friends, it's me (BruceB) again with a brief lesson on break detection on the Amiga. I think someone actually requested this information, but we're busy guys (and gals) around here and don't always keep track. Anyway, I needed this for my current application so thought I'd share it. If you don't have or don't want to use Lattice's routines for ^C detection you can do the following instead (see program). [BTW Lattice has to be doing something real similar.] Also please note that if your program does a Wait() anyway you can include the ^C (^D, ^E, or ^F) flags as well. Please be warned that SetSignal() will clear the bit you are checking so you should look at oldsigs rather than calling SetSignal() again. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* mybreak.c - look for break (^C) */ /* Note: This does NOT require any of the Lattice libraries or */ /* run time routines. */ /* Public domain, ,and you're welcome to it! */ #include "libraries/dos.h" /* Needed for the control-C */ /* bit number */ main() { int loop; LONG newsigs; LONG oldsigs; loop = TRUE; newsigs = 0; while (loop) { Delay(15); /* Keep it slow */ printf("*"); oldsigs = SetSignal(newsigs, 1 << SIGBREAKB_CTRL_C); if (oldsigs & (1 << SIGBREAKB_CTRL_C) ) { printf ("\nControl-C detected.\nDone.\n"); loop = FALSE; } /* end if if */ } /* end of while */ } /* end of main */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Enjoy! Bruce Barrett