contrib/mul/mbl/mbl_read_yes.cxx
Go to the documentation of this file.
00001 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00002 #pragma implementation
00003 #endif
00004 //:
00005 // \file
00006 // \author Tim Cootes
00007 // \brief Get yes or no response from keyboard
00008 
00009 #include "mbl_read_yes.h"
00010 #include <vcl_iostream.h>
00011 #include <vcl_cstdio.h>
00012 
00013 bool mbl_read_yes()
00014 {
00015    vcl_cout<<" (N) ";
00016    vcl_cout.flush();  // This forces display of any previous text.
00017       // and allows something like
00018       //   vcl_cout<<"Continue?";
00019       //   if (RD_GetYes()) ...
00020       // to work properly. Without this, the
00021       // "Continue?" vcl_string isn't displayed
00022       // until return pressed.
00023    int c;
00024    bool r = false;
00025    while ((c=vcl_getchar())!='\n') {   /* Loop till return pressed */
00026       if (c=='y' || c=='Y')
00027          r = true;  /* If a Y is entered, return true */
00028    }
00029    return r;
00030 }
00031 
00032 bool mbl_read_no()
00033 {
00034    vcl_cout<<" (Y) ";
00035    vcl_cout.flush();  // This forces display of any previous text.
00036    int c;
00037    bool r = false;
00038    while ((c=vcl_getchar())!='\n') {   /* Loop till return pressed */
00039       if (c=='n' || c=='N')
00040          r = true;  /* If a N is entered, return true */
00041    }
00042    return r;
00043 }