function Num=asknumber(num, nmin, nmax, tit) %ASKNUMBER Ask to input a number in the rigth corner of the figure. % % NUM=ASKNUMBER(NUM, MIN, MAX, TITLE) % % NUM is the original number, default is 0. % MIN is the minimal value that the number can have. % MAX is the maximal value that the number can have. % TITLE a string. % % Return the number only when ENTER key is pressed. % % Claudio May 14, 1995 % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global Uibgcolor Handlefig frame uitit uied nmin nmax if nargin > 4 error('Too many input arguments.'); end if nargin < 4 tit=''; end if nargin < 3 nmax=inf; end if nargin < 2 nmin=-inf; end if nargin < 1 num=0; end fpos = [0.8026, 0.9250, 0.1974, 0.070]; titpos= [0.8076, 0.9670, 0.1874, 0.025]; edpos = [0.85, 0.936, 0.1, 0.03]; frame = uicontrol(Handlefig, 'Style', 'frame',... 'Units', 'Normalized',... 'Position', fpos,... 'BackgroundColor', Uibgcolor); uitit = uicontrol(Handlefig, 'Style', 'text',... 'String', tit,... 'Units', 'normalized',... 'Position', [fpos(1)+0.005 fpos(2)+fpos(4)-0.028, fpos(3)-0.01, 0.025],... 'HorizontalAlignment', 'center',... 'BackgroundColor', Uibgcolor); uied=uicontrol(Handlefig, 'Style', 'edit',... 'String', num2str(num),... 'Units', 'normalized',... 'position', edpos,... 'Value', num,... 'UserData', 0,... 'HorizontalAlignment', 'center'); while 1 if waitforbuttonpress == 1 k=get(gcf, 'CurrentCharacter'); if abs(k) == 13 break; end end end editstr2value(uied,nmin,nmax); Num=get(uied, 'value'); delete(frame, uitit, uied); return