home *** CD-ROM | disk | FTP | other *** search
- #include <curses.h>
- #include <ctype.h>
- #include "c_term.h"
-
- void get_hosp_num (HospNum)
- char *HospNum;
-
- /*
- ---------------------------------------------------------------------------
-
- Last revision -
- 6 January 1985 - GWS
- Change it to use curses
-
- 16 November 1984 - GWS
- Ignore XON, XOFF
-
- 11 April 1984 - GWS
-
-
- NAME
- get_hosp_num - "crash-proof" routine for terminal input of ##-##-##
-
- SYNOPSIS
- void get_hosp_num(HospNum)
- char *HospNum;
-
- DESCRIPTION
- This routine prompts and nudges the user through entry of a
- hospital number in the proper format.
-
- SEE ALSO
-
-
- DIAGNOSTICS
- none
-
- BUGS
- Doesn't do any validity checking on the number, only the format.
-
- AUTHOR
- George W. Sherouse
- 9 April 1984
-
- ---------------------------------------------------------------------------
- */
-
- {
- int c;
- int count,
- where_y,
- where_x,
- x,
- y;
-
- getyx(stdscr, where_y, where_x);
- standout();
-
- printw(" - - ");
- move(where_y, where_x);
- refresh();
-
- count = 0;
- while (1)
- {
- switch (count)
- {
- case 2:
- case 5:
- printw("-");
- HospNum[count++] = '-';
- break;
- default:
- switch (c = (getchar() & 0177))
- {
- #ifdef ABORT_CHAR
- case ABORT_CHAR:
- clear();
- standend();
- mvprintw(0, 0, "Program aborted at your request...");
- move(LINES - 1, 0);
- refresh();
- endwin();
- exit(0);
- break;
- #endif ABORT_CHAR
-
- case '\015':
- if (count == 8)
- {
- HospNum[8] = (char) 0;
- standend();
- mvprintw(where_y, where_x, HospNum);
- refresh();
- return;
- }
- else
- {
- fprintf(stderr, "%c", '\007');
- break;
- }
- case 030:
- mvprintw(where_y, where_x, " - - ");
- move(where_y, where_x);
- count = 0;
- break;
- case '\021':
- case '\023':
- break;
- default:
- if (c == erase_char && count)
- {
- switch (count)
- {
- case 3:
- case 6:
- getyx(stdscr, y, x);
- move(y, x - 1);
- count--;
- case 1:
- case 2:
- case 4:
- case 5:
- case 7:
- case 8:
- getyx(stdscr, y, x);
- mvprintw(y, x - 1, " ");
- move(y, x - 1);
- HospNum[--count] = 0;
- break;
- }
- break;
- }
-
- if (isdigit(c) && count < 8)
- {
- printw("%c", c);
- HospNum[count++] = (char) c;
- }
- else
- fprintf(stderr, "%c", '\007');
- }
- }
- refresh();
- }
- }
-