File: mbl_read_yes.cxx

package info (click to toggle)
vxl 1.17.0.dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 153,280 kB
  • ctags: 105,123
  • sloc: cpp: 747,420; ansic: 209,130; fortran: 34,230; lisp: 14,915; sh: 6,187; python: 5,856; makefile: 340; perl: 294; xml: 160
file content (43 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifdef VCL_NEEDS_PRAGMA_INTERFACE
#pragma implementation
#endif
//:
// \file
// \author Tim Cootes
// \brief Get yes or no response from keyboard

#include "mbl_read_yes.h"
#include <vcl_iostream.h>
#include <vcl_cstdio.h>

bool mbl_read_yes()
{
   vcl_cout<<" (N) ";
   vcl_cout.flush();  // This forces display of any previous text.
      // and allows something like
      //   vcl_cout<<"Continue?";
      //   if (RD_GetYes()) ...
      // to work properly. Without this, the
      // "Continue?" vcl_string isn't displayed
      // until return pressed.
   int c;
   bool r = false;
   while ((c=vcl_getchar())!='\n') {   /* Loop till return pressed */
      if (c=='y' || c=='Y')
         r = true;  /* If a Y is entered, return true */
   }
   return r;
}

bool mbl_read_no()
{
   vcl_cout<<" (Y) ";
   vcl_cout.flush();  // This forces display of any previous text.
   int c;
   bool r = false;
   while ((c=vcl_getchar())!='\n') {   /* Loop till return pressed */
      if (c=='n' || c=='N')
         r = true;  /* If a N is entered, return true */
   }
   return r;
}