home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR23 / TOUCH2.ZIP / STAT.C < prev    next >
C/C++ Source or Header  |  1993-08-14  |  16KB  |  849 lines

  1. /*
  2.  * stat.c - manage meter status
  3.  *
  4.  * V. Abell
  5.  */
  6.  
  7. /*
  8.  * Copyright 1993 Victor A. Abell, Lafayette, Indiana  47906.  All rights
  9.  * reserved.
  10.  *
  11.  * Written by Victor A. Abell.
  12.  *
  13.  * Permission is granted to anyone to use this software for any purpose on
  14.  * any computer system, and to alter it and redistribute it freely, subject
  15.  * to the following restrictions:
  16.  *
  17.  * 1. Victor A. Abell is not responsible for any consequences of the use of
  18.  * this software.
  19.  *
  20.  * 2. The origin of this software must not be misrepresented, either by
  21.  *    explicit claim or by omission.  Credit to Victor A. Abell must
  22.  *    appear in documentation and sources.
  23.  *
  24.  * 3. Altered versions must be plainly marked as such, and must not be
  25.  *    misrepresented as being the original software.
  26.  *
  27.  * 4. This notice may not be removed or altered.
  28.  */
  29. #ifndef lint
  30. static char copyright[] =
  31. "@(#) Copyright 1993 Victor A. Abell.\nAll rights reserved.\n";
  32. #endif
  33.  
  34. #include "touch2.h"
  35. #include <string.h>
  36. #include <ctype.h>
  37.  
  38. struct menu BaudMenu[] = {
  39.     { 12, 19, "Changing the baud rate is not permitted." },
  40.     {  0,  0,  NULL },
  41. };
  42.  
  43. struct menu CmdFail[] = {
  44.     { 12, 32, "Command failed" },
  45.     {  0,  0, NULL },
  46. };
  47.  
  48. struct menu McommMenu[] = {
  49.     { 12, 14, "Changing the communications mode is not permitted." },
  50.     {  0,  0,  NULL },
  51. };
  52.  
  53. struct menu StatusType[] = {
  54.     {  2, 25, "Inspect or change meter status." },
  55.     { 10, 25, "C - Change meter status" },
  56.     { 12, 25, "I - Inspect meter status" },
  57.     { 14, 25, "X - eXit" },
  58.     {  0,  0, NULL},
  59. };
  60.  
  61. #define BEEPLN        8
  62. #define    COL        25
  63. #define    CALLN        BEEPLN+1
  64. #define    DTLN        CALLN+1
  65. #define    LANLN        DTLN+1
  66. #define COMMLN        LANLN+1
  67. #define    PUNLN        COMMLN+1
  68. #define    BAUDLN        PUNLN+1
  69. #define STATLN        16
  70. #define    TMLN        BAUDLN+1
  71. #define    UNLN        TMLN+1
  72. #define XLN        UNLN+1
  73.  
  74.  
  75. char Mbaud[STATLN];            /* baud rate */
  76. char Mbeep[STATLN];            /* beeper */
  77. char Mcal[STATLN];            /* calibration */
  78. char Mcomm[STATLN];            /* communications mode */
  79. char Mdate[STATLN];                     /* date format */
  80. char Mlang[STATLN];            /* language */
  81. char Mmax[STATLN];            /* maximum reading */
  82. char Mmin[STATLN];            /* minimum reading */
  83. char Mpunc[STATLN];            /* MMOL/L punctuation */
  84. char Mserial[STATLN];            /* meter serial number */
  85. char Mtime[STATLN];            /* time format */
  86. char Munits[STATLN];            /* MMOL/L units */
  87. short Ndump = 0;            /* number of dump lines */
  88.  
  89. static int ChangeBeep();
  90. static int ChangeCal();
  91. static int ChangeDate();
  92. static int ChangeLang();
  93. static int ChangeMcomm();
  94. static int ChangePunc();
  95. static int ChangeBaud();
  96. static int ChangeTime();
  97. static int ChangeUnits();
  98.  
  99. #if    defined(UNIX)
  100. static void CopyReply(char *s, char *d, int dl);
  101. #else
  102. static void CopyReply(char *s, char *d, short dl);
  103. #endif
  104.  
  105. #if    defined(UNIX)
  106. static int ReadVal(int c, char *b, int bl);
  107. #else
  108. static int ReadVal(char c, char *b, short bl);
  109. #endif
  110.  
  111. static void StatusCh();
  112. static void StatusIn();
  113. static void StatusMenu(char *t, char *b);
  114.  
  115. #if    defined(UNIX)
  116. static int WriteVal(char *c, char *r, int rl);
  117. #else
  118. static int WriteVal(char *c, char *r, short rl);
  119. #endif
  120.  
  121.  
  122. /*
  123.  * ChangeBaud() - change baud rate (not permitted)
  124.  */
  125.  
  126. static int
  127. ChangeBaud()
  128. {
  129.     DispMenu(BaudMenu, "Press any key to continue.");
  130.     (void) WaitAnyKey();
  131.     return(1);
  132. }
  133.  
  134.  
  135. /*
  136.  * ChangeBeep() - change beep status
  137.  */
  138.  
  139. static int
  140. ChangeBeep()
  141. {
  142.     char b[8], r[STATLN];
  143.  
  144.     for (;;) {
  145.         _clearscreen(_GCLEARSCREEN);
  146.         if (GetInp(12, 10, "Beep or nobeep?", "", b, sizeof(b)) == 0)
  147.             return(0);
  148.         if (strcmpi(b, "beep") == 0) {
  149.             b[1] = '0';
  150.             break;
  151.         } else if (strcmpi(b, "nobeep") == 0) {
  152.             b[1] = '1';
  153.             break;
  154.         }
  155.         putch(BELL);
  156.     }
  157.     *b = 'B';
  158.     b[2] = '\0';
  159.     if (WriteVal(b, r, sizeof(r))) {
  160.         (void) strcpy(Mbeep, r);
  161.         return(1);
  162.     }
  163.     return(0);
  164. }
  165.  
  166.  
  167. /*
  168.  * ChangeCal() - change the strip lot calibration code
  169.  */
  170.  
  171. static int
  172. ChangeCal()
  173. {
  174.     char b[4], r[STATLN];
  175.     int n;
  176.  
  177.     for (;;) {
  178.         _clearscreen(_GCLEARSCREEN);
  179.         if (GetInp(12, 10, "1 through 16?", "", b, sizeof(b)) == 0)
  180.             return(0);
  181.         n = atoi(b);
  182.         if (n >= 1 && n <= 16)
  183.             break;
  184.         putch(BELL);
  185.     }
  186.     *b = 'S';
  187.     b[1] = (n < 11) ? (char)(n - 1 + '0') : (char)(n - 11 + 'A');
  188.     b[2] = '\0';
  189.     if (WriteVal(b, r, sizeof(r))) {
  190.         (void) strcpy(Mcal, r);
  191.         return(1);
  192.     }
  193.     return(0);
  194. }
  195.  
  196.  
  197. /*
  198.  * ChangeDate() - change date format
  199.  */
  200.  
  201. static int
  202. ChangeDate()
  203. {
  204.     char b[8], r[STATLN];
  205.  
  206.     for (;;) {
  207.         _clearscreen(_GCLEARSCREEN);
  208.         if (GetInp(12, 10, "M.D.Y or D.M.Y?", "", b, sizeof(b)) == 0)
  209.             return(0);
  210.         if (strcmpi(b, "m.d.y") == 0) {
  211.             b[1] = '0';
  212.             break;
  213.         } else if (strcmpi(b, "d.m.y") == 0) {
  214.             b[1] = '1';
  215.             break;
  216.         }
  217.         putch(BELL);
  218.     }
  219.     *b = 'D';
  220.     b[2] = '\0';
  221.     if (WriteVal(b, r, sizeof(r))) {
  222.         (void) strcpy(Mdate, r);
  223.         return(1);
  224.     }
  225.     return(0);
  226. }
  227.  
  228.  
  229. /*
  230.  * ChangeLang() - change meter language
  231.  */
  232.  
  233. static int
  234. ChangeLang()
  235. {
  236.     char b[8], r[STATLN];
  237.  
  238.     for (;;) {
  239.         _clearscreen(_GCLEARSCREEN);
  240.         if (GetInp(12, 10,
  241.             "ENGL|ESPAN|FRANC|ITALII|NEDER|PORT|SVENS|DEUTS|SYMB?",
  242.             "", b, sizeof(b)) == 0)
  243.             return(0);
  244.         if (strcmpi(b, "engl") == 0) {
  245.             b[1] = '0';
  246.             break;
  247.         } else if (strcmpi(b, "espan") == 0) {
  248.             b[1] = '1';
  249.             break;
  250.         } else if (strcmpi(b, "franc") == 0) {
  251.             b[1] = '2';
  252.             break;
  253.         } else if (strcmpi(b, "itali") == 0) {
  254.             b[1] = '3';
  255.             break;
  256.         } else if (strcmpi(b, "neder") == 0) {
  257.             b[1] = '4';
  258.             break;
  259.         } else if (strcmpi(b, "port") == 0) {
  260.             b[1] = '5';
  261.             break;
  262.         } else if (strcmpi(b, "svens") == 0) {
  263.             b[1] = '6';
  264.             break;
  265.         } else if (strcmpi(b, "deuts") == 0) {
  266.             b[1] = '7';
  267.             break;
  268.         } else if (strcmpi(b, "symb") == 0) {
  269.             b[1] = '8';
  270.             break;
  271.         }
  272.         putch(BELL);
  273.     }
  274.     *b = 'L';
  275.     b[2] = '\0';
  276.     if (WriteVal(b, r, sizeof(r))) {
  277.         (void) strcpy(Mlang, r);
  278.         Mbeep[0] = Mcal[0] = Mpunc[0] ='\0';
  279.         return(1);
  280.     }
  281.     return(0);
  282. }
  283.  
  284.  
  285. /*
  286.  * ChangeMcomm() - change the communications mode (not permitted)
  287.  */
  288.  
  289. static int
  290. ChangeMcomm()
  291. {
  292.     DispMenu(McommMenu, "Press any key to continue.");
  293.     (void) WaitAnyKey();
  294.     return(1);
  295. }
  296.  
  297.  
  298. /*
  299.  * ChangePunc() - change punctuation
  300.  */
  301.  
  302. static int
  303. ChangePunc()
  304. {
  305.     char b[8], r[STATLN];
  306.  
  307.     for (;;) {
  308.         _clearscreen(_GCLEARSCREEN);
  309.         if (GetInp(12, 10, "DEC PT or COMMA?", "", b, sizeof(b)) == 0)
  310.             return(0);
  311.         if (strcmpi(b, "dec pt") == 0) {
  312.             b[1] = '0';
  313.             break;
  314.         } else if (strcmpi(b, "comma") == 0) {
  315.             b[1] = '1';
  316.             break;
  317.         }
  318.         putch(BELL);
  319.     }
  320.     *b = 'P';
  321.     b[2] = '\0';
  322.     if (WriteVal(b, r, sizeof(r))) {
  323.         (void) strcpy(Mpunc, r);
  324.         return(1);
  325.     }
  326.     return(0);
  327. }
  328.  
  329.  
  330. /*
  331.  * ChangeTime() - change time format
  332.  */
  333.  
  334. static int
  335. ChangeTime()
  336. {
  337.     char b[8], r[STATLN];
  338.  
  339.     for (;;) {
  340.         _clearscreen(_GCLEARSCREEN);
  341.         if (GetInp(12, 10, "AM/PM or 24:00?", "", b, sizeof(b)) == 0)
  342.             return(0);
  343.         if (strcmpi(b, "am/pm") == 0) {
  344.             b[1] = '0';
  345.             break;
  346.         } else if (strcmp(b, "24:00") == 0) {
  347.             b[1] = '1';
  348.             break;
  349.         }
  350.         putch(BELL);
  351.     }
  352.     *b = 'T';
  353.     b[2] = '\0';
  354.     if (WriteVal(b, r, sizeof(r))) {
  355.         (void) strcpy(Mtime, r);
  356.         return(1);
  357.     }
  358.     return(0);
  359. }
  360.  
  361.  
  362. /*
  363.  * ChangeUnits() - change units
  364.  */
  365.  
  366. static int
  367. ChangeUnits()
  368. {
  369.     char b[8], r[STATLN];
  370.  
  371.     for (;;) {
  372.         _clearscreen(_GCLEARSCREEN);
  373.         if (GetInp(12, 10, "MG/DL or MMOL/L?", "", b, sizeof(b)) == 0)
  374.             return(0);
  375.         if (strcmpi(b, "mg/dl") == 0) {
  376.             b[1] = '0';
  377.             break;
  378.         } else if (strcmpi(b, "mmol/l") == 0) {
  379.             b[1] = '1';
  380.             break;
  381.         }
  382.         putch(BELL);
  383.     }
  384.     *b = 'U';
  385.     b[2] = '\0';
  386.     if (WriteVal(b, r, sizeof(r))) {
  387.         (void) strcpy(Munits, r);
  388.         return(1);
  389.     }
  390.     return(0);
  391. }
  392.  
  393.  
  394. /*
  395.  * CopyReply() - copy command reply
  396.  */
  397.  
  398. static void
  399. CopyReply(s, d, dl)
  400.     char *s;            /* source */
  401.     char *d;            /* destination */
  402.     short dl;            /* destination limit */
  403. {
  404.     short i;
  405.  
  406.     for (i = 0; i < dl - 1; i++) {
  407.         if (*s == '\0' || *s == '"')
  408.             break;
  409.         *d++ = *s++;
  410.     }
  411.     *d = '\0';
  412. }
  413.  
  414.  
  415. /*
  416.  * InitStatus() - initialize status
  417.  */
  418.  
  419. void
  420. InitStatus()
  421. {
  422.     Mbaud[0] = Mbeep[0] = Mcal[0] = Mcomm[0] = Mdate[0] = '\0';
  423.     Mlang[0] = Mpunc[0] = Mserial[0] = Mtime[0] = Munits[0] = '\0';
  424. }
  425.  
  426.  
  427. /*
  428.  * ParseField() - parse '"' delimited field
  429.  */
  430.  
  431. char *
  432. ParseField(p, b, l)
  433.     char *p;            /* field pointer */
  434.     char *b;            /* destination buffer */
  435.     int l;                /* destination length */
  436. {
  437.     int i;
  438.  
  439.     if ((p = strchr(p, '"')) == NULL)
  440.         return(NULL);
  441.     for (p++, i = 0; *p; p++, i++) {
  442.         if (*p == '"')
  443.             break;
  444.         if (i > (l - 2))
  445.             return(NULL);
  446.         b[i] = *p;
  447.     }
  448.     b[i] = '\0';
  449.     return(++p);
  450. }
  451.  
  452.  
  453. /*
  454.  * ParseHdr() - parse dump header
  455.  */
  456.  
  457. int
  458. ParseHdr()
  459. {
  460.     char *cp;
  461.     int i;
  462.  
  463.     DumpHs = 0;
  464. /*
  465.  * Get record count.
  466.  */
  467.     if ((cp = strchr(DumpLine, ' ')) == NULL)
  468.         return(0);
  469.     while(*cp == ' ') {
  470.         cp++;
  471.     }
  472.     for (Ndump = 0; *cp; cp++) {
  473.         if ( ! isdigit(*cp))
  474.             break;
  475.         Ndump = Ndump * 10 + *cp - '0';
  476.     }
  477. /*
  478.  * Get serial number.
  479.  */
  480.     if ((cp = ParseField(cp, Mserial, sizeof(Mserial))) == NULL)
  481.         return(0);
  482. /*
  483.  * Get language code.
  484.  */
  485.     if ((cp = ParseField(cp, Mlang, sizeof(Mlang))) == NULL)
  486.         return(0);
  487. /*
  488.  * Get date format.
  489.  */
  490.     if ((cp = ParseField(cp, Mdate, sizeof(Mdate))) == NULL)
  491.         return(0);
  492. /*
  493.  * Get time format.
  494.  */
  495.     if ((cp = ParseField(cp, Mtime, sizeof(Mtime))) == NULL)
  496.         return(0);
  497. /*
  498.  * Get units format.
  499.  */
  500.     if ((cp = ParseField(cp, Munits, sizeof(Munits))) == NULL)
  501.         return(0);
  502. /*
  503.  * Get minimum reading.
  504.  */
  505.     if ((cp = ParseField(cp, Mmin, sizeof(Mmin))) == NULL)
  506.         return(0);
  507. /*
  508.  * Get maximum reading.
  509.  */
  510.     if ((cp = ParseField(cp, Mmax, sizeof(Mmax))) == NULL)
  511.         return(0);
  512.     DumpHs = 1;
  513.     return(1);
  514. }
  515.  
  516.  
  517. /*
  518.  * ReadVal() - read meter status value
  519.  */
  520.  
  521. static int
  522. ReadVal(c, b, bl)
  523.  
  524. #if    defined(UNIX)
  525.     int c;                /* value code */
  526.     char *b;            /* destination buffer */
  527.     int bl;                /* buffer length */
  528. #else
  529.     char c;                /* value code */
  530.     char *b;            /* destination buffer */
  531.     short bl;            /* buffer length */
  532. #endif
  533.  
  534. {
  535.     char cmd[5], *cp;
  536.  
  537.     (void) sprintf(cmd, "DMS%c?", c);
  538.     *b = '\0';
  539.     for (;;) {
  540.         if (WaitRdy() == 0)
  541.             return(0);
  542.         if (WaitCmd(cmd, c)) {
  543.             (void) GetDataLn(DumpLine, DUMPLL);
  544.             if ((cp = strchr(DumpLine, '"')) == NULL)
  545.                 return(0);
  546.             break;
  547.         }
  548.         DispMenu(CmdFail,
  549.             "Press ESC to exit; any other key to retry.");
  550.         if ((char)WaitAnyKey() == ESC)
  551.             return(0);
  552.     }
  553.     CopyReply(++cp, b, bl);
  554.     return(1);
  555. }
  556.  
  557.  
  558. /*
  559.  * StatusCh() - change meter status
  560.  */
  561. static void
  562. StatusCh()
  563. {
  564.     int ch;
  565.  
  566.     StatusMenu("Change meter status", "Press ESC to exit.");
  567.     for (;;) {
  568.         if ( ! kbhit()) {
  569.             reset_buffer();
  570.             continue;
  571.         }
  572.         ch = getch();
  573.         switch (ch) {
  574.  
  575.         case 'b':
  576.         case 'B':
  577.             if ( ! ChangeBeep())
  578.                 return;
  579.             break;
  580.         case 'c':
  581.         case 'C':
  582.             if ( ! ChangeCal())
  583.                 return;
  584.             break;
  585.         case 'd':
  586.         case 'D':
  587.             if ( ! ChangeDate())
  588.                 return;
  589.             break;
  590.         case 'l':
  591.         case 'L':
  592.             if ( ! ChangeLang())
  593.                 return;
  594.             break;
  595.         case 'm':
  596.         case 'M':
  597.             if ( ! ChangeMcomm())
  598.                 return;
  599.             break;
  600.         case 'p':
  601.         case 'P':
  602.             if ( ! ChangePunc())
  603.                 return;
  604.             break;
  605.         case 'r':
  606.         case 'R':
  607.             if ( ! ChangeBaud())
  608.                 return;
  609.             break;
  610.         case 't':
  611.         case 'T':
  612.             if ( ! ChangeTime())
  613.                 return;
  614.             break;
  615.         case 'u':
  616.         case 'U':
  617.             if ( ! ChangeUnits())
  618.                 return;
  619.             break;
  620.         case 'x':
  621.         case 'X':
  622.         case ESC:
  623.             return;
  624.         default:
  625.             if (ch == 0)
  626.                 ch = getch();
  627.             putch(BELL);
  628.         }
  629.         StatusMenu("Change meter status", "Press ESC to exit.");
  630.     }
  631. }
  632.  
  633.  
  634. /*
  635.  * StatusIn() - inspect meter status
  636.  */
  637.  
  638. static void
  639. StatusIn()
  640. {
  641.     int ch;
  642.  
  643.     StatusMenu("Inspect meter status", "Press ESC to exit.");
  644.     for (;;) {
  645.         if ( ! kbhit()) {
  646.             reset_buffer();
  647.             continue;
  648.         }
  649.         ch = getch();
  650.         switch (ch) {
  651.  
  652.         case 'b':
  653.         case 'B':
  654.             if ( ! ReadVal('B', Mbeep, sizeof(Mbeep)))
  655.                 return;
  656.             break;
  657.         case 'c':
  658.         case 'C':
  659.             if ( ! ReadVal('S', Mcal, sizeof(Mcal)))
  660.                 return;
  661.             break;
  662.         case 'd':
  663.         case 'D':
  664.             if ( ! ReadVal('D', Mdate, sizeof(Mdate)))
  665.                 return;
  666.             break;
  667.         case 'l':
  668.         case 'L':
  669.             if ( ! ReadVal('L', Mlang, sizeof(Mlang)))
  670.                 return;
  671.             break;
  672.         case 'm':
  673.         case 'M':
  674.             if ( ! ReadVal('C', Mcomm, sizeof(Mcomm)))
  675.                 return;
  676.             break;
  677.         case 'p':
  678.         case 'P':
  679.             if ( ! ReadVal('P', Mpunc, sizeof(Mpunc)))
  680.                 return;
  681.             break;
  682.         case 'r':
  683.         case 'R':
  684.             if ( ! ReadVal('R', Mbaud, sizeof(Mbaud)))
  685.                 return;
  686.             break;
  687.         case 't':
  688.         case 'T':
  689.             if ( ! ReadVal('T', Mtime, sizeof(Mtime)))
  690.                 return;
  691.             break;
  692.         case 'u':
  693.         case 'U':
  694.             if ( ! ReadVal('U', Munits, sizeof(Munits)))
  695.                 return;
  696.             break;
  697.         case 'x':
  698.         case 'X':
  699.         case ESC:
  700.             return;
  701.         default:
  702.             if (ch == 0)
  703.                 ch = getch();
  704.             putch(BELL);
  705.         }
  706.         StatusMenu("Inspect meter status", "Press ESC to exit.");
  707.     }
  708. }
  709.  
  710.  
  711. /*
  712.  * StatusMenu() - display status menu
  713.  */
  714.  
  715. static void
  716. StatusMenu(ttl, bot)
  717.     char *ttl;            /* menu title */
  718.     char *bot;            /* text for bottom line */
  719. {
  720.     char b[64];
  721.  
  722.     _clearscreen(_GCLEARSCREEN);
  723.     _settextposition(2, COL);
  724.     _outtext(ttl);
  725.     if (Mserial[0]) {
  726.         _settextposition(3, COL+1);
  727.         (void) sprintf(b, "(serial: %s)", Mserial);
  728.         _outtext(b);
  729.     }
  730.     PromptMsg(bot);
  731.     (void) sprintf(b, "B - Beeper status: %s", Mbeep);
  732.     ClearRow(BEEPLN, COL);
  733.     _settextposition(BEEPLN, COL);
  734.     _outtext(b);
  735.     (void) sprintf(b, "C - strip lot Calibration code: %s", Mcal);
  736.     ClearRow(CALLN, COL);
  737.     _settextposition(CALLN, COL);
  738.     _outtext(b);
  739.     (void) sprintf(b, "D - Date format: %s", Mdate);
  740.     ClearRow(DTLN, COL);
  741.     _settextposition(DTLN, COL);
  742.     _outtext(b);
  743.     (void) sprintf(b, "L - message and prompt Language: %s", Mlang);
  744.     ClearRow(LANLN, COL);
  745.     _settextposition(LANLN, COL);
  746.     _outtext(b);
  747.     (void) sprintf(b, "M - communications Mode: %s", Mcomm);
  748.     ClearRow(COMMLN, COL);
  749.     _settextposition(COMMLN, COL);
  750.     _outtext(b);
  751.     (void) sprintf(b, "P - MMOL/L Punctuation: %s", Mpunc);
  752.     ClearRow(PUNLN, COL);
  753.     _settextposition(PUNLN, COL);
  754.     _outtext(b);
  755.     (void) sprintf(b, "R - baud Rate: %s", Mbaud);
  756.     ClearRow(BAUDLN, COL);
  757.     _settextposition(BAUDLN, COL);
  758.     _outtext(b);
  759.     (void) sprintf(b, "T - Time display format: %s", Mtime);
  760.     ClearRow(TMLN, COL);
  761.     _settextposition(TMLN, COL);
  762.     _outtext(b);
  763.     (void) sprintf(b, "U - glucose Units: %s", Munits);
  764.     ClearRow(UNLN, COL);
  765.     _settextposition(UNLN, COL);
  766.     _outtext(b);
  767.     _settextposition(XLN, COL);
  768.     _outtext("X - eXit");
  769. }
  770.  
  771.  
  772. /*
  773.  * StatusMtr() - inspect/change meter status
  774.  */
  775.  
  776. void
  777. StatusMtr()
  778. {
  779.     int ch;
  780.  
  781.     DispMenu(StatusType, NULL);
  782.     for (;;) {
  783.         if ( !kbhit()) {
  784.             reset_buffer();
  785.             continue;
  786.         }
  787.         ch = getch();
  788.         switch(ch) {
  789.  
  790.         case 'c':
  791.         case 'C':
  792.             StatusCh();
  793.             break;
  794.         case 'i':
  795.         case 'I':
  796.             StatusIn();
  797.             break;
  798.         case 'x':
  799.         case 'X':
  800.         case ESC:
  801.             return;
  802.         default:
  803.             if (ch == 0)
  804.                 ch = getch();
  805.             putch(BELL);
  806.         }
  807.         DispMenu(StatusType, NULL);
  808.     }
  809. }
  810.  
  811.  
  812. /*
  813.  * WriteVal() - write meter status value
  814.  */
  815.  
  816. int
  817. WriteVal(c, r, rl)
  818.     char *c;            /* command */
  819.     char *r;            /* result */
  820.  
  821. #if    defined(UNIX)
  822.     int rl;                /* result buffer length */
  823. #else
  824.     short rl;            /* result buffer length */
  825. #endif
  826.  
  827. {
  828.     char cmd[6], *cp;
  829.  
  830.     (void) sprintf(cmd, "DMS%c%c", *c, *(c+1));
  831.     *r = '\0';
  832.     for (;;) {
  833.         if (WaitRdy() == 0)
  834.             return(0);
  835.         if (WaitCmd(cmd, *c)) {
  836.             (void) GetDataLn(DumpLine, DUMPLL);
  837.             if ((cp = strchr(DumpLine, '"')) == NULL)
  838.                 return(0);
  839.             break;
  840.         }
  841.         DispMenu(CmdFail,
  842.             "Press ESC to exit; any other key to retry.");
  843.         if ((char)WaitAnyKey() == ESC)
  844.             return(0);
  845.     }
  846.     CopyReply(++cp, r, rl);
  847.     return(1);
  848. }
  849.