Home > matlab > dyn_waitbar.m

dyn_waitbar

PURPOSE ^

h = dyn_waitbar(prctdone, varargin)

SYNOPSIS ^

function h = dyn_waitbar(prctdone, varargin)

DESCRIPTION ^

 h = dyn_waitbar(prctdone, varargin)
 adaptive waitbar, producing console mode waitbars with
 octave and when console_mode=1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h = dyn_waitbar(prctdone, varargin)
0002 % h = dyn_waitbar(prctdone, varargin)
0003 % adaptive waitbar, producing console mode waitbars with
0004 % octave and when console_mode=1
0005 
0006 %
0007 % Copyright (C) 2011 Dynare Team
0008 %
0009 % This file is part of Dynare.
0010 %
0011 % Dynare is free software: you can redistribute it and/or modify
0012 % it under the terms of the GNU General Public License as published by
0013 % the Free Software Foundation, either version 3 of the License, or
0014 % (at your option) any later version.
0015 %
0016 % Dynare is distributed in the hope that it will be useful,
0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 % GNU General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU General Public License
0022 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0023 global options_
0024 persistent running_text newString
0025 persistent whoiam Parallel
0026 
0027 if iscell(prctdone)
0028     whoiam = prctdone{2};
0029     Parallel = prctdone{3};
0030     prctdone=prctdone{1};
0031 end
0032 
0033 if prctdone==0,
0034     init=1;
0035     if isempty(whoiam)
0036         whoiam=0;
0037     end
0038 else
0039     init=0;
0040 end
0041 if nargout,
0042     h=[];
0043 end
0044 
0045 if ~whoiam
0046     
0047     if exist('OCTAVE_VERSION') || options_.console_mode,
0048                 
0049         if init,
0050             diary off;
0051             running_text = varargin{1};
0052             newString='';
0053             return;
0054         elseif nargin>2,
0055             running_text =  varargin{2};
0056         end
0057         
0058         if exist('OCTAVE_VERSION'),
0059             printf([running_text,' %3.f%% done\r'], prctdone*100);
0060         else
0061             s0=repmat('\b',1,length(newString));
0062             newString=sprintf([running_text,' %3.f%% done'], prctdone*100);
0063             fprintf([s0,'%s'],newString);
0064         end
0065         
0066     else
0067         if nargout,
0068             h = waitbar(prctdone,varargin{:});
0069         else
0070             waitbar(prctdone,varargin{:});
0071         end
0072     end
0073     
0074 else
0075     if init,
0076         running_text = varargin{1};
0077     elseif nargin>2
0078         running_text = varargin{2};
0079     end
0080     if Parallel.Local,
0081         waitbarTitle=['Local '];
0082     else
0083         waitbarTitle=[Parallel.ComputerName];
0084     end
0085     fMessageStatus(prctdone,whoiam,running_text, waitbarTitle, Parallel);
0086 end
0087

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005