home *** CD-ROM | disk | FTP | other *** search
- /*
- * gotodos.c
- * contains: gotodos(),kbflush(),getyn(),escape()
- *
- * Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "gfuncts.h"
- #include "ibmkeys.h"
-
-
- /*
- * void
- * gotodos(void)
- *
- * DESCRIPTION
- * Clear the screen, display a message in the middle of the screen, and
- * a response is solicited (y/n). If 'y', an immediate exit is taken
- * to DOS. Otherwise, the function returns.
- *
- * MODIFICATIONS
- *
- */
- void GF_CONV gotodos()
- {
- cls();
- atsay(12,10,"Do you want to exit to DOS ? (y/n) ");
- if(getyn()==YES)
- exit(0);
- }
-
- /*
- * void
- * kbflush(void)
- *
- * DESCRIPTION
- * This functions removes all characters from the keyboard queue
- * via rom bios.
- */
- void GF_CONV kbflush()
- {
- while(gfkbhit())
- kbfetch();
- }
-
- /*
- * char
- * getyn()
- *
- * DESCRIPTION
- * The keyboard is read using getkey(), a 'y' or 'Y' or 'n' or 'N' or
- * ESC or Ctrl-Break must be entered to return from this function. Y/N
- * entries also cause "YES" or "NO" to be displayed on stdout.
- *
- * RETURNS
- * 0 = 'n' or 'N' entered
- * 1 = 'y' or 'Y' entered
- * 0x1b (ESC) = ESC entered
- * 2 = Ctrl-Break entered
- */
- char GF_CONV getyn()
- {
- unsigned c;
-
- while (FOREVER) {
- c = getkey();
- if ((c=='y')||(c=='Y')) {
- prints("YES");
- return YES;
- } else if((c=='n')||(c=='N')) {
- prints("NO");
- return NO;
- }
- else if(c==ESC)
- return ESC;
- else if(c==0)
- return 2; /* Ctrl-Break */
- }
- }
-
- /*
- * void
- * escape(void)
- *
- * DESCRIPTION
- * The keyboard is tested (via gfkbhit()); If there is no keystroke return
- * If there is a keystroke, fetch it and test for ESCAPE, if so exit to
- * dos.
- */
- void GF_CONV escape()
- {
- if(!gfkbhit())
- return;
- else if(getkey()==ESC)
- exit(0);
- }
-