annotate private/EDB1myvalueinput.m @ 18:2d5f50205527 jabuilder_int tip

Escape the trailing backslash as well
author Chris Cannam
date Tue, 30 Sep 2014 16:23:00 +0100
parents 90220f7249fc
children
rev   line source
tp@0 1 function outval = EDB1myvalueinput(textstr,nvalues,minval,maxval)
tp@0 2 % EDB1myvalueinput - Prints a text on the screen and waits for a numerical to be input.
tp@0 3 % Prints the text in textstr, and waits for a numerical to be input.
tp@0 4 % It is checked if these are within the range [minval,maxval].
tp@0 5 % If one or both is not specified, or given as [], an open range
tp@0 6 % is used. It is also checked if exactly nvalues are input. The
tp@0 7 % values should be input with spaces inbetween. If a negative
tp@0 8 % value of nvalues is input, any number will be accepted.
tp@0 9 %
tp@0 10 % Input parameters:
tp@0 11 % textstr A text str which will be printed on the screen.
tp@0 12 % nvalues The number of numerical values that should be read in from
tp@0 13 % the keyboard.
tp@0 14 % minval (optional) The lowest value that should be allowed.
tp@0 15 % maxval (optional) The highest value that should be allowed.
tp@0 16 %
tp@0 17 % Output parameters:
tp@0 18 % outval The nvalues numerical values that should be read in.
tp@0 19 %
tp@0 20 % Uses the function EDB1extrnums
tp@0 21 %
tp@0 22 % ----------------------------------------------------------------------------------------------
tp@0 23 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
tp@0 24 %
tp@0 25 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
tp@0 26 % it under the terms of the GNU General Public License as published by the Free Software
tp@0 27 % Foundation, either version 3 of the License, or (at your option) any later version.
tp@0 28 %
tp@0 29 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
tp@0 30 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
tp@0 31 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
tp@0 32 %
tp@0 33 % You should have received a copy of the GNU General Public License along with the
tp@0 34 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
tp@0 35 % ----------------------------------------------------------------------------------------------
tp@0 36 % Peter Svensson (svensson@iet.ntnu.no) 20030602
tp@0 37 %
tp@0 38 % outval = EDB1myvalueinput(textstr,nvalues,minval,maxval);
tp@0 39
tp@0 40 if nargin < 4
tp@0 41 maxval = 1e9;
tp@0 42 if nargin < 3
tp@0 43 minval = -1e9;
tp@0 44 end
tp@0 45 end
tp@0 46 if isempty(maxval)
tp@0 47 maxval = 1e9;
tp@0 48 end
tp@0 49 if isempty(minval)
tp@0 50 minval = -1e9;
tp@0 51 end
tp@0 52 if maxval < minval
tp@0 53 error(['ERROR: minval > maxval'])
tp@0 54 end
tp@0 55
tp@0 56 foundOKvalue = 0;
tp@0 57 while foundOKvalue == 0
tp@0 58 outval = EDB1extrnums( input(textstr,'s') );
tp@0 59 if length(outval) ~= nvalues & nvalues >= 0
tp@0 60 disp('Wrong number of values!');
tp@0 61 else
tp@0 62 if prod( double(outval >= minval) ) & prod( double(outval <= maxval) )
tp@0 63 foundOKvalue = 1;
tp@0 64 else
tp@0 65 disp('One value is outside the allowed range!');
tp@0 66 end
tp@0 67 end
tp@0 68 end