Home > classes > @history > display.m

display

PURPOSE ^

DISPLAY implement terminal display for history object.

SYNOPSIS ^

function txt = display(hists, varargin)

DESCRIPTION ^

 DISPLAY implement terminal display for history object.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: DISPLAY implement terminal display for history object.

 CALL:        txt = display(history)

 INPUT:       history - history object

 OUTPUT:      txt     - cell array with strings to display the history object

 VERSION:     $Id: display.m,v 1.9 2008/01/08 16:39:11 ingo Exp $

 HISTORY:     30-01-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function txt = display(hists, varargin)
0002 % DISPLAY implement terminal display for history object.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DISPLAY implement terminal display for history object.
0007 %
0008 % CALL:        txt = display(history)
0009 %
0010 % INPUT:       history - history object
0011 %
0012 % OUTPUT:      txt     - cell array with strings to display the history object
0013 %
0014 % VERSION:     $Id: display.m,v 1.9 2008/01/08 16:39:11 ingo Exp $
0015 %
0016 % HISTORY:     30-01-2007 M Hewitson
0017 %                 Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 VERSION = '$Id: display.m,v 1.9 2008/01/08 16:39:11 ingo Exp $';
0022 
0023 % Check if this is a call for parameters
0024 if nargin == 2
0025   if isa(hists, 'history') && ischar(varargin{1})
0026     in = char(varargin{1});
0027     if strcmp(in, 'Params')
0028       txt = plist();
0029       return
0030     elseif strcmp(in, 'Version')
0031       txt = VERSION;
0032       return
0033     end
0034   end
0035 end
0036 
0037 txt = {};
0038 
0039 for i=1:numel(hists)
0040   h = hists(i);
0041   banner = sprintf('-------- %s / %s / %d ------------', get(h, 'name'),    ...
0042                                                          get(h, 'version'), ...
0043                                                          get(h, 'n'));
0044   txt{end+1} = banner;
0045 
0046   txt{end+1} = ' ';
0047   txt{end+1} = sprintf('created: %s', char(h.created));
0048 
0049   % show input vars
0050   txt{end+1} = ['Inputs: ' get(h, 'invars')];
0051 
0052   % show parameter list
0053   txt{end+1} = 'Parameters';
0054   txt{end+1} = '----------';
0055   pl = get(h, 'plist');
0056   if ~isempty(pl)
0057     txt{end+1} = display(pl);
0058   end
0059 
0060   txt{end+1} = ' ';
0061 
0062   txt{end+1} = 'Histories';
0063   txt{end+1} = '---------';
0064 
0065   % show input histories
0066   inhists = get(h, 'inhists');
0067   nhists = length(inhists);
0068   txt{end+1} = sprintf('n input histories: %d', nhists);
0069   if nhists > 0
0070     txt{end+1} = display(inhists);
0071   end
0072 
0073   txt{end+1} = ' ';
0074 
0075   bannerEnd = [];
0076   while length(bannerEnd) < length(banner)
0077     bannerEnd = [bannerEnd '-'];
0078   end
0079   txt{end+1} = bannerEnd;
0080 
0081   txt{end+1} = ' ';
0082   txt{end+1} = ' ';
0083 end
0084 
0085 txt = single_cell(txt);
0086 
0087 if nargout == 0
0088   for ii=1:length(txt)
0089     disp(txt{ii});
0090   end
0091 end
0092 
0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094 
0095 function new_txt = single_cell(txt_field)
0096 
0097 new_txt = {};
0098 for ii=1:length(txt_field)
0099   if iscell(txt_field{ii})
0100     hh = single_cell(txt_field{ii});
0101     new_txt(end+1:end+length(hh)) = hh(1:end);
0102   else
0103     new_txt{end+1} = txt_field{ii};
0104   end
0105 end
0106 
0107 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003