home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2989 / select.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-06  |  15.4 KB  |  950 lines

  1.  
  2. /*+
  3.  * File: select.c
  4.  *
  5.  * Description:
  6.  *   Display a list of items for selection.
  7.  *
  8.  * This module is the proprietary property of Cottege Computing
  9.  * copyright 1989, all rights reserved.
  10.  *
  11.  * Audit Trail:
  12.  *   SCCSID = @(#) select.c 1.2 11/20/89 15:05:06
  13.  *   Dan Flak - 11/7/89
  14.  *
  15. -*/
  16.  
  17. /* #includes                            */
  18. #include <curses.h>
  19.  
  20. /* #defines                             */
  21. #define SAY    printf
  22.  
  23. #define RETURN    '\015'
  24. #define ESC       '\033'
  25. #define BACKSPACE '\010'
  26.  
  27. #define MAX(x,y) (((x) < (y)) ? y : x)
  28. #define MIN(x,y) (((x) > (y)) ? y : x)
  29. #define WINLEN 20
  30. #define ARRAYPOS linenum + irow + lastline * icol
  31.  
  32. #define UP    1
  33. #define DOWN  2
  34. #define LEFT  3
  35. #define RIGHT 4
  36.  
  37. #define ON    1
  38. #define OFF   0
  39.  
  40. /* external variables                   */
  41.  
  42. /* referenced external functions        */
  43.  
  44. /* referenced internal functions        */
  45. char *closewin();
  46. char *select();
  47. int  do_esc();
  48. void errormsg();
  49. void newpage();
  50. void homecursor();
  51. void putcursor();
  52. void mvcursor();
  53. void scroll();
  54. void redraw();
  55. void wrap();
  56.  
  57. /* global variables                     */
  58.  
  59. char *rtnstr = NULL;                    /* return string (item selected)   */
  60. char cmdstr[32];                        /* printf format string            */
  61.  
  62. int  arraypos = 0;                        /* item position in array          */
  63. int  center;                            /* center of the screen               */
  64. int  column = 0;                        /* column number                   */
  65. int  lastline;                            /* last line in the array          */
  66. int  linenum = 0;                        /* line number                     */
  67. int  ncol = 1;                          /* number of columns               */
  68. int  screenx = 0, screeny = 0;            /* x and y screen positions        */
  69.  
  70. WINDOW *win1, *win2, *win3;                /* information, command and work-  */
  71.                                         /* ing windows                     */
  72.  
  73.  
  74. /* static variables                     */
  75.  
  76.  
  77. /*<
  78.  * Function: select (array, narray, width)
  79.  *
  80.  * Description:
  81.  *   Select an item from an array.
  82.  *
  83.  * Data Type: char *
  84.  *
  85.  * Arguments:
  86.  *   array  - the array containing the selection items
  87.  *  narray  - number of items in the array.
  88.  *   width  - string length of items in the array.
  89.  *
  90.  * Returns:
  91.  *   pointer to a string containing the item name.
  92.  *
  93.  * Side Effects:
  94.  *
  95.  * Calls:
  96.  *
  97.  * PDL:
  98.  *
  99. >*/
  100.  
  101. char *
  102. select (array, narray, width)
  103. char *array[];
  104. int  narray;
  105. int  width;
  106. {
  107. int i;
  108.  
  109. ncol = 80 / (6 + width);                /* determine number of columns     */
  110. center = 40 - (6 + width) / 2;
  111.  
  112. if (ncol > 10 || ncol < 1)                /* will display fit on screen?     */
  113.     {
  114.     return (closewin (-2));
  115.     }
  116.  
  117. lastline = narray / ncol;                /* compute total number of lines   */
  118. if (narray % ncol)
  119.     {
  120.     lastline++;
  121.     }
  122.  
  123. sprintf (cmdstr, "%c3d %c-%d.%ds", '%', '%', width, width);
  124.  
  125. initscr();
  126. crmode ();
  127. noecho ();
  128. nonl();
  129.  
  130. win1 = newwin ( 2, 80,  0,  0);            /* top information window          */
  131. win2 = newwin (WINLEN, 80,  2,  0);        /* working window                  */
  132. win3 = newwin ( 2, 80, 22,  0);         /* command window                  */
  133.  
  134. wmove (win1, 0, 0);                        /* print instructions              */
  135. waddstr (win1, "Use arrow keys and <RETURN> to select from menu or");
  136. wmove (win1, 1, 0);
  137. waddstr (win1, "'#' to enter number or <SPACE> to enter name. <ESC>Q quits");
  138. wrefresh (win1);
  139.  
  140. wclear (win2);
  141. redraw (array, narray);                    /* show intial set of items           */
  142. homecursor(array);
  143.  
  144. while (getcmds(array, narray))            /* get commands                    */
  145.     {
  146.     homecursor(array);                    /* put cursor at bottom of screen  */
  147.     }
  148.  
  149. return (closewin(0));
  150. }
  151.  
  152.  
  153. /*<
  154.  * Function: getcmds (array narray)
  155.  *
  156.  * Description:
  157.  *   Get cursor commands
  158.  *
  159.  * Data Type: int
  160.  *
  161.  * Arguments:
  162.  *   array - the array containing the items
  163.  *  narray - the number of elements in the array
  164.  *
  165.  * Returns:
  166.  *    0 - upon <ESC>q.
  167.  *    0 - upon confirmation of selection.
  168.  *    1 - all other cases.
  169.  *
  170.  * Side Effects:
  171.  *
  172.  * Calls:
  173.  *
  174.  * PDL:
  175.  *
  176. >*/
  177.  
  178. int
  179. getcmds (array, narray)
  180. char *array[];
  181. int  narray;
  182. {
  183. int c;
  184.  
  185. c = wgetch (win3);
  186.  
  187. switch (c)
  188.     {
  189.     case ESC:
  190.         return (do_esc(array, narray));
  191.     break;
  192.     case ' ':
  193.         return (do_string (array, narray));
  194.     break;
  195.     case '#':
  196.         return (do_number(array, narray));
  197.     break;
  198.     case RETURN:
  199.         rtnstr = array[arraypos];
  200.         return (confirm());
  201.     break;
  202.     default:
  203.         return (1);
  204.     break;
  205.     }
  206. }
  207.  
  208.  
  209. /*<
  210.  * Function: do_esc (array, narray)
  211.  *
  212.  * Description:
  213.  *   Evaluate ESC sequences for cursor moves, scroll, wrap and
  214.  *      paging.
  215.  *
  216.  * Data Type: int
  217.  *
  218.  * Arguments:
  219.  *   array - array of display items
  220.  *  narray - number of elements in array
  221.  *
  222.  * Returns:
  223.  *   0 for <ESC>Q
  224.  *   1 for anything else
  225.  *
  226.  * Side Effects:
  227.  *
  228.  * Calls:
  229.  *
  230.  * PDL:
  231.  *
  232. >*/
  233.  
  234. int
  235. do_esc (array, narray)
  236. char *array[];
  237. int narray;
  238. {
  239. int c;
  240.  
  241. c = wgetch (win3);
  242.  
  243. if (c == '[')                            /* it's an arrow key               */
  244.     {
  245.     c = wgetch (win3);
  246.     switch (c)
  247.         {
  248.         case 'A':                        /* up arrow                       */
  249.             if (screeny == 0 && linenum > 0)
  250.                 {                        /* if at top with items above     */
  251.                 scroll (UP, array, narray);
  252.                 }
  253.             else if (screeny > 0)          /* cursor below top line          */
  254.                 {
  255.                 mvcursor (UP, array, narray);
  256.                 }
  257.         break;
  258.         case 'B':                        /* down arrow                     */
  259.             if (screeny == WINLEN -1 && linenum + WINLEN < lastline)
  260.                 {                        /* if on bottom with items below  */
  261.                 scroll (DOWN, array, narray);
  262.                 }
  263.             else if (screeny < MIN (WINLEN - 1, lastline - 1))
  264.                 {                        /* cursor above bottom line          */
  265.                 mvcursor (DOWN, array, narray);
  266.                 }
  267.         break;
  268.         case 'C':                        /* right arrow                    */
  269.             if (screenx < (80 * (ncol - 1)) / ncol)
  270.                 {                        /* if not in right column          */
  271.                 mvcursor (RIGHT, array, narray);
  272.                 }
  273.             else if (screenx == (80 * (ncol - 1)) / ncol)
  274.                 {                        /* if in right column              */
  275.                 wrap (RIGHT, array, narray);
  276.                 }
  277.         break;
  278.         case 'D':                        /* left arrow                     */
  279.             if (screenx > 0)
  280.                 {                        /* if not in left column          */
  281.                 mvcursor (LEFT, array, narray);
  282.                 }
  283.             else
  284.                 {                        /* in left column                  */
  285.                 wrap (LEFT, array, narray);
  286.                 }
  287.         break;
  288.         }
  289.     }                                    /* end case arrow                 */
  290. else 
  291.     {
  292.     switch (c)
  293.         {
  294.         case 'N': case 'n':                /* Next page                       */
  295.             linenum = MIN (linenum + 2 * WINLEN, lastline) - WINLEN;
  296.             newpage ();
  297.             redraw (array, narray);
  298.         break;
  299.         case 'P': case 'p':                /* Previous page                   */
  300.             linenum = MAX (0, linenum - WINLEN);
  301.             newpage ();
  302.             redraw (array, narray);
  303.         break;
  304.         case 'T': case 't':                /* Top of scroll                   */
  305.             linenum = 0;
  306.             newpage ();
  307.             redraw (array, narray);
  308.         break;
  309.         case 'B': case 'b':                /* Bottom of scroll                */
  310.             linenum = MAX(0, lastline - WINLEN);
  311.             newpage ();
  312.             redraw (array, narray);
  313.         break;
  314.         case 'R': case 'r':
  315.             wclear (win2);
  316.             redraw (array, narray);
  317.         break;
  318.         case 'Q': case 'q':                /* Quit                               */
  319.             return (0);
  320.         break;
  321.         }
  322.     }                                    /* end case anything else          */
  323. return (1);
  324. }
  325.  
  326.  
  327. /*<
  328.  * Function: closewin (n)
  329.  *
  330.  * Description:
  331.  *   Close the windows gracefully
  332.  *
  333.  * Data Type: char *
  334.  *
  335.  * Arguments:
  336.  *    n = exit code
  337.  *
  338.  * Returns:
  339.  *
  340.  * Side Effects:
  341.  *
  342.  * Calls:
  343.  *
  344.  * PDL:
  345.  *
  346. >*/
  347.  
  348. char *
  349. closewin (n)
  350. int n;
  351. {
  352. werase (win1);
  353. werase (win2);
  354. werase (win3);
  355.  
  356. wrefresh (win1);
  357. wrefresh (win2);
  358. wrefresh (win3);
  359.  
  360. endwin ();
  361.  
  362. if (n)                                    /* If error                        */
  363.     {
  364.     return (NULL);                      /* Return pointer to a null        */
  365.     }
  366. else
  367.     {
  368.     return (rtnstr);                    /* Return pointer to selected item */
  369.     }
  370. }
  371.  
  372.  
  373. /*<
  374.  * Function: redraw (array, narray)
  375.  *
  376.  * Description:
  377.  *    Redraw the working screen
  378.  *
  379.  * Data Type: void
  380.  *
  381.  * Arguments:
  382.  *    array - array of items to display.
  383.  *   narray - number of elements in the array
  384.  *
  385.  * Returns: None
  386.  *
  387.  * Side Effects:
  388.  *
  389.  * Calls:
  390.  *
  391.  * PDL:
  392.  *
  393. >*/
  394.  
  395. void
  396. redraw(array, narray)
  397. char *array[];
  398. int  narray;
  399. {
  400. int irow, icol;                            /* screen row and column number    */
  401.  
  402. for (irow = 0; irow < MIN (lastline, WINLEN); irow++)
  403.     {
  404.     for (icol = 0; icol < ncol; icol++) /* for each row and column         */
  405.         {
  406.         wmove (win2, irow, (80 * icol) / ncol);
  407.         if (ARRAYPOS == arraypos)       /* highlight the selection         */
  408.             {
  409.             wstandout (win2);
  410.             }
  411.         else
  412.             {
  413.             wstandend (win2);
  414.             }
  415.         if ((irow + linenum < lastline) + ncol && icol == ncol -1)
  416.             {                            /* clear old items in last column  */
  417.             wclrtoeol (win2);
  418.             }
  419.         if (ARRAYPOS < narray)            /* Print all if you can            */
  420.             {
  421.             wprintw (win2, cmdstr, ARRAYPOS + 1, array[ARRAYPOS]);
  422.             }
  423.         }
  424.     }
  425. wrefresh (win2);
  426. }
  427.  
  428.  
  429. /*<
  430.  * Function: mvcursor (n, array, narray)
  431.  *
  432.  * Description:
  433.  *   Move the cursor in the indicated direction.
  434.  *
  435.  * Data Type: void
  436.  *
  437.  * Arguments:
  438.  *       n = direction to move the cursor
  439.  *   array = array of display items
  440.  *  narray = number of items in the array
  441.  *
  442.  * Returns:
  443.  *
  444.  * Side Effects:
  445.  *
  446.  * Calls:
  447.  *
  448.  * PDL:
  449.  *
  450. >*/
  451.  
  452. void
  453. mvcursor (n, array, narray)
  454. int  n;
  455. char *array[];
  456. int  narray;
  457. {
  458. putcursor (OFF, array);
  459.  
  460. switch (n)
  461.     {
  462.     case UP:
  463.         screeny--;
  464.         arraypos--;
  465.     break;
  466.     case DOWN:
  467.         if (arraypos + 1 < narray)
  468.             {
  469.             screeny++;
  470.             arraypos++;
  471.             }
  472.     break;
  473.     case LEFT:
  474.         column--;
  475.         screenx = (80 * column) / ncol;
  476.         arraypos -= lastline;
  477.     break;
  478.     case RIGHT:
  479.         if (arraypos +  lastline < narray)
  480.             {
  481.             column++;
  482.             screenx = (80 * column) / ncol;
  483.             arraypos += lastline;
  484.             }
  485.     break;
  486.     }
  487. putcursor (ON, array);
  488. }
  489.  
  490.  
  491. /*<
  492.  * Function: putcursor (n, array)
  493.  *
  494.  * Description:
  495.  *   Print an item in normal or highlight mode.
  496.  *
  497.  * Data Type: void
  498.  *
  499.  * Arguments:
  500.  *   n = highlight mode (0 = off, 1 = on)
  501.  *   array = array of display items.
  502.  *
  503.  * Returns:
  504.  *
  505.  * Side Effects:
  506.  *
  507.  * Calls:
  508.  *
  509.  * PDL:
  510.  *
  511. >*/
  512.  
  513. void
  514. putcursor (n, array)
  515. int  n;
  516. char *array[];
  517. {
  518. wmove (win2, screeny, screenx);
  519. if (n)
  520.     {
  521.     wstandout (win2);
  522.     }
  523. else
  524.     {
  525.     wstandend (win2);
  526.     }
  527.  
  528. wprintw (win2, cmdstr, arraypos + 1, array[arraypos]);
  529. wrefresh (win2);
  530. }
  531.  
  532.  
  533. /*<
  534.  * Function: scroll (n, array, narray)
  535.  *
  536.  * Description:
  537.  *   Scroll the page.
  538.  *
  539.  * Data Type: void
  540.  *
  541.  * Arguments:
  542.  *        n = direction of scroll
  543.  *    array = array of display items
  544.  *   narray = number of items in the array
  545.  *
  546.  * Returns:
  547.  *
  548.  * Side Effects:
  549.  *
  550.  * Calls:
  551.  *
  552.  * PDL:
  553.  *
  554. >*/
  555.  
  556. void
  557. scroll (n, array, narray)
  558. int  n;
  559. char *array[];
  560. int  narray;
  561. {
  562. switch (n)
  563.     {
  564.     case UP:
  565.         linenum--;
  566.         arraypos--;
  567.     break;
  568.     case DOWN:
  569.         linenum++;
  570.         arraypos++;
  571.     break;
  572.     }
  573. redraw (array, narray);
  574. }
  575.  
  576.  
  577. /*<
  578.  * Function: wrap (n, array, narray)
  579.  *
  580.  * Description:
  581.  *   Wrap the cursor
  582.  *
  583.  * Data Type: void
  584.  *
  585.  * Arguments:
  586.  *   n = direction of wrap
  587.  *   array = display items
  588.  *  narray = number of items in the array
  589.  *
  590.  * Returns:
  591.  *
  592.  * Side Effects:
  593.  *
  594.  * Calls:
  595.  *
  596.  * PDL:
  597.  *
  598. >*/
  599.  
  600. void
  601. wrap (n, array, narray)
  602. int  n;
  603. char *array[];
  604. int narray;
  605. {
  606. putcursor (OFF, array);
  607.  
  608. switch (n)
  609.     {
  610.     case LEFT:
  611.         if (arraypos + lastline * (ncol - 1) < narray)
  612.             {
  613.             column = ncol - 1;
  614.             screenx = (80 * column) / ncol;
  615.             arraypos += lastline * (ncol - 1);
  616.             }
  617.     break;
  618.     case RIGHT:
  619.         column = 0;
  620.         screenx = 0;
  621.         arraypos -= lastline * (ncol - 1);
  622.     break;
  623.     }
  624.  
  625. putcursor (ON, array);
  626. }
  627.  
  628.  
  629. /*<
  630.  * Function: do_number (array, narray)
  631.  *
  632.  * Description:
  633.  *   Get a number from the keyboard and match it to an item selection.
  634.  *
  635.  * Data Type: int
  636.  *
  637.  * Arguments:
  638.  *    array = array of display items
  639.  *   narray = numbr of elements in the array.
  640.  *
  641.  * Returns:
  642.  *   0 - if item is confirmed
  643.  *   1 - if item is not confirmed
  644.  *   1 - if item is not found.
  645.  *
  646.  * Side Effects:
  647.  *
  648.  * Calls:
  649.  *
  650.  * PDL
  651.  *
  652. >*/
  653.  
  654. int 
  655. do_number (array, narray) 
  656. char *array[];
  657. int  narray;
  658. {
  659. char number[16];
  660. int  n;
  661.  
  662. echo ();
  663. nl();
  664.  
  665. werase (win3);                            /* clear the window                   */
  666. wmove (win3, 0, 0);                        /* position the cursor               */
  667. waddstr (win3, "ENTER ITEM NUMBER: ");  /* write the prompt                   */
  668. wmove (win3, 0, 19);                    /* position the cursor               */
  669. wrefresh (win3);                        /* redraw the window               */
  670. wgetstr (win3, number);                    /* get a string                       */
  671. wrefresh (win3); werase (win3); wrefresh (win3);
  672.  
  673. noecho();
  674. nonl();
  675.  
  676. wmove (win3, 0, center);                /* move the cursor                   */
  677.  
  678. n = atoi (number);
  679. if (n > 0 && n <= narray)
  680.     {
  681.     wprintw (win3, cmdstr , n, array [n-1]);
  682.     rtnstr = array [n-1];
  683.     return (confirm ());
  684.     }
  685. else
  686.     {
  687.     wprintw (win3, "%3d is not a good item number", n);
  688.     errormsg();
  689.     return (1);
  690.     }
  691. }
  692.  
  693.  
  694. /*<
  695.  * Function: do_string (array, narray)
  696.  *
  697.  * Description:
  698.  *   Get a name from the keyboard and match it to an item selection.
  699.  *
  700.  * Data Type: int
  701.  *
  702.  * Arguments:
  703.  *    array = array of display items
  704.  *   narray = numbr of elements in the array.
  705.  *
  706.  * Returns:
  707.  *   0 - if item is confirmed
  708.  *   1 - if item is not confirmed
  709.  *   1 - if item is not found.
  710.  *
  711.  * Side Effects:
  712.  *
  713.  * Calls:
  714.  *
  715.  * PDL
  716.  *
  717. >*/
  718.  
  719. int 
  720. do_string (array, narray)
  721. char *array[];
  722. int  narray;
  723. {
  724. int  i;
  725. int  found = 0;
  726. char name[128];
  727.  
  728. echo ();
  729. nl();
  730.  
  731. werase (win3);                            /* clear the window                   */
  732. wmove (win3, 0, 0);                        /* position the cursor               */
  733. waddstr (win3, "ENTER ITEM NAME:");        /* write the prompt                   */
  734. wmove (win3, 0, 18);                    /* position the cursor               */
  735. wrefresh (win3);                        /* redraw the window               */
  736. wgetstr (win3, name);                    /* get a string                       */
  737. wrefresh (win3); werase (win3); wrefresh (win3);
  738.  
  739. noecho();
  740. nonl();
  741.  
  742. wmove (win3, 0, center);                 /* move the cursor                   */
  743.  
  744. for (i = 0; i < narray; i++)
  745.     {
  746.     if (strcmp (name, array[i]) == 0)
  747.         {
  748.         found = 1;
  749.         break;
  750.         }
  751.     }
  752.  
  753. if (found)
  754.     {
  755.     wprintw (win3, cmdstr , i + 1, array [i]);
  756.     rtnstr = array [i];
  757.     return (confirm ());
  758.     }
  759. else
  760.     {
  761.     wprintw (win3, "%s is not a good item name", name);
  762.     errormsg();
  763.     return (1);
  764.     }
  765. }
  766.  
  767.  
  768. /*<
  769.  * Function: homecursor (array)
  770.  *
  771.  * Description:
  772.  *   Print the current slection in win3
  773.  *
  774.  * Data Type: void
  775.  *
  776.  * Arguments:
  777.  *    array - the array containing the select items
  778.  *
  779.  * Returns:
  780.  *
  781.  * Side Effects:
  782.  *
  783.  * Calls:
  784.  *
  785.  * PDL:
  786.  *
  787. >*/
  788.  
  789. void
  790. homecursor (array)
  791. char *array[];
  792. {
  793. wmove (win3, 0, center);
  794. wprintw (win3, cmdstr, arraypos + 1, array[arraypos]);
  795. wrefresh (win3);
  796. }
  797.  
  798.  
  799. /*<
  800.  * Function: newpage ()
  801.  *
  802.  * Description:
  803.  *    Set up fresh page on <ESC> T, B, N and P.
  804.  *
  805.  * Data Type: void
  806.  *
  807.  * Arguments: globals
  808.  *
  809.  * Returns: globals
  810.  *
  811.  * Side Effects:
  812.  *
  813.  * Calls:
  814.  *
  815.  * PDL:
  816.  *
  817. >*/
  818.  
  819. void 
  820. newpage ()
  821. {
  822. if (isonpage ())
  823.     {                                    /* item still on page               */
  824.     screeny = arraypos - linenum - column * lastline;
  825.     }
  826. else
  827.     {                                    /* item scrolled off page           */
  828.     arraypos = linenum;                    /* "home" the item number           */
  829.     column = 0;                            /* and everthing else               */
  830.     screenx = 0;
  831.     screeny = 0;
  832.     }
  833. }
  834.  
  835.  
  836. /*<
  837.  * Function: isonpage ()
  838.  *
  839.  * Description:
  840.  *   Determine if an item is still on the page after paging.
  841.  *
  842.  * Data Type: int
  843.  *
  844.  * Arguments: globals
  845.  *
  846.  * Returns: globals
  847.  *
  848.  * Side Effects:
  849.  *
  850.  * Calls:
  851.  *
  852.  * PDL
  853.  *
  854. >*/
  855.  
  856. int
  857. isonpage ()
  858. {
  859. int i;
  860.  
  861. for (i = 0; i < ncol; i++)
  862.     {
  863.     if (arraypos >= linenum + i * lastline &&
  864.         arraypos <= linenum + WINLEN - 1 + i * lastline)
  865.         {
  866.         return (1);
  867.         }
  868.     }
  869. return (0);
  870. }
  871.  
  872.  
  873. /*<
  874.  * Function: confirm ()
  875.  *
  876.  * Description:
  877.  *   Confirm a user's selection.
  878.  *
  879.  * Data Type: int
  880.  *
  881.  * Arguments:
  882.  *
  883.  * Returns:
  884.  *   0 - if the item is confirmed
  885.  *   1 - if the item is not confirmed
  886.  *
  887.  * Side Effects:
  888.  *
  889.  * Calls:
  890.  *
  891.  * PDL
  892.  *
  893. >*/
  894.  
  895. int
  896. confirm ()
  897. {
  898. int c;
  899.  
  900. wmove (win3, 1, 20);
  901. waddstr (win3, "Do you wish to select this item? (y/n) ");
  902. wrefresh (win3);
  903.  
  904. c = wgetch (win3);
  905.  
  906. if (c == 'y' || c == 'Y')
  907.     {
  908.     return (0);
  909.     }
  910. else
  911.     {
  912.     werase (win3);
  913.     wrefresh (win3);
  914.     rtnstr = NULL;
  915.     return (1);
  916.     }
  917. }
  918.  
  919.  
  920. /*<
  921.  * Function: errormsg()
  922.  *
  923.  * Description:
  924.  *   Pause the processing to let the user read an error message. Wait
  925.  *   for a keystroke.
  926.  *
  927.  * Data Type: void
  928.  *
  929.  * Arguments:
  930.  *
  931.  * Returns:
  932.  *
  933.  * Side Effects:
  934.  *
  935.  * Calls:
  936.  *
  937.  * PDL
  938.  *
  939. >*/
  940.  
  941. void
  942. errormsg()
  943. {
  944. wmove (win3, 1, 28);
  945. waddstr (win3, "Press any key to continue");
  946. wrefresh (win3);
  947. wgetch (win3);
  948. werase (win3); wrefresh (win3);
  949. }
  950.