diff yesnoQuestion.m @ 11:0c166d195f58

Allowed no defult answer in yesnoQuestion.m
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 21 Sep 2015 18:01:57 +0200
parents 9551f4e7cb66
children
line wrap: on
line diff
--- a/yesnoQuestion.m	Mon Sep 21 17:58:04 2015 +0200
+++ b/yesnoQuestion.m	Mon Sep 21 18:01:57 2015 +0200
@@ -1,10 +1,12 @@
 function b = yesnoQuestion(question, defaultAnswer)
-    default_arg('defaultAnswer','y');
+    default_arg('defaultAnswer','nodefault');
 
     yesAnswer = {'y','Y','yes','Yes','YES'};
     noAnswer = {'n','N','no','No','NO'};
 
     switch defaultAnswer
+        case 'nodefault'
+            optionString = '[y/n]';
         case yesAnswer
             optionString = '[Y/n]';
             yesAnswer{end+1} = '';
@@ -17,7 +19,7 @@
 
     b = [];
     while isempty(b)
-        answer = input([question ' ' optionString ':'],'s');
+        answer = input([question ' ' optionString ': '],'s');
         switch answer
             case yesAnswer
                 b = true;