<p><b>dwj07@fsu.edu</b> 2012-04-06 13:02:08 -0600 (Fri, 06 Apr 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Fixing the clearing of the input buffer on invalid input.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/tools/mpas_draw/netcdf_utils.cpp
===================================================================
--- branches/tools/mpas_draw/netcdf_utils.cpp        2012-04-06 18:31:50 UTC (rev 1754)
+++ branches/tools/mpas_draw/netcdf_utils.cpp        2012-04-06 19:02:08 UTC (rev 1755)
@@ -808,7 +808,8 @@
        int i;
        int j;
        int valid = 0;
-        int choice = 0;
+        int choice = -1;
+        bool failed;
        vector<string> excluded_vars;
@@ -879,11 +880,21 @@
                        cout << ncid.get_var(var_ids.at(i))->get_dim(num_dims-1)->name() << endl;
                }
                cout << endl << endl;
-
                cout << "Enter the number of the field you would like to print" << endl;
                cout << "Choose from list above, or enter 0 for default:" << endl;
-                cin >> choice;
+                do{
+                        cin >> choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="gray">');
+                                cout << "Invalid input or the input buffer needed to be cleared. Please try again." << endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
+
                for(i = 0; i < var_ids.size(); i++){
                        if(var_ids.at(i) == choice){
                                valid = 1;
@@ -946,6 +957,7 @@
        int j;
        int choice = 0;
        int valid = 0;
+        bool failed;
        vector<string> excluded_vars;
@@ -1020,7 +1032,17 @@
                cout << "Enter the number of the field you would like to print" << endl;
                cout << "Choose from list above, or enter 0 for default:" << endl;
-                cin >> choice;
+                do{
+                        cin >> choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="gray">');
+                                cout << "Invalid input or the input buffer needed to be cleared. Please try again." << endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
                for(i = 0; i < var_ids.size(); i++){
                        if(var_ids.at(i) == choice){
@@ -1085,6 +1107,7 @@
        int j;
        int choice = 0;
        int valid = 0;
+        bool failed;
        vector<string> excluded_vars;
@@ -1156,7 +1179,17 @@
                cout << endl << endl;
                cout << "Enter the number of the field you would like to print" << endl;
                cout << "Choose from list above, or enter 0 for default:" << endl;
-                cin >> choice;
+                do{
+                        cin >> choice;
+                        if(cin.fail()){
+                                failed = true;
+                                cin.clear();
+                                cin.ignore(1024,'</font>
<font color="blue">');
+                                cout << "Invalid input or the input buffer needed to be cleared. Please try again." << endl;
+                        } else {
+                                failed = false;
+                        }
+                }while(failed);
                for(i = 0; i < var_ids.size(); i++){
                        if(var_ids.at(i) == choice){
</font>
</pre>