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.html,v 1.14 2008/03/31 10:27:38 hewitson 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.html,v 1.14 2008/03/31 10:27:38 hewitson Exp $
0015 %
0016 % HISTORY:     30-01-2007 M Hewitson
0017 %                 Creation
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 VERSION  = '$Id: display.html,v 1.14 2008/03/31 10:27:38 hewitson Exp $';
0022 CATEGORY = 'Output';
0023 
0024 % Check if this is a call for parameters
0025 if nargin == 2
0026   if isa(hists, 'history') && ischar(varargin{1})
0027     in = char(varargin{1});
0028     if strcmp(in, 'Params')
0029       txt = plist();
0030       return
0031     elseif strcmp(in, 'Version')
0032       txt = VERSION;
0033       return
0034     elseif strcmp(in, 'Category')
0035       txt = CATEGORY;
0036       return
0037     end
0038   end
0039 end
0040 
0041 txt = {};
0042 
0043 for i=1:numel(hists)
0044   h = hists(i);
0045   banner = sprintf('-------- %s / %s / %d ------------', get(h, 'name'),    ...
0046                                                          get(h, 'version'), ...
0047                                                          get(h, 'n'));
0048   txt{end+1} = banner;
0049 
0050   txt{end+1} = ' ';
0051   txt{end+1} = sprintf('created: %s', char(h.created));
0052 
0053   % show input vars
0054   txt{end+1} = ['Inputs: ' get(h, 'invars')];
0055 
0056   % show parameter list
0057   txt{end+1} = 'Parameters';
0058   txt{end+1} = '----------';
0059   pl = get(h, 'plist');
0060   if ~isempty(pl)
0061     txt{end+1} = display(pl);
0062   end
0063 
0064   txt{end+1} = ' ';
0065 
0066   txt{end+1} = 'Histories';
0067   txt{end+1} = '---------';
0068 
0069   % show input histories
0070   inhists = get(h, 'inhists');
0071   nhists = length(inhists);
0072   txt{end+1} = sprintf('n input histories: %d', nhists);
0073   if nhists > 0
0074     txt{end+1} = display(inhists);
0075   end
0076 
0077   txt{end+1} = ' ';
0078 
0079   bannerEnd = [];
0080   while length(bannerEnd) < length(banner)
0081     bannerEnd = [bannerEnd '-'];
0082   end
0083   txt{end+1} = bannerEnd;
0084 
0085   txt{end+1} = ' ';
0086   txt{end+1} = ' ';
0087 end
0088 
0089 txt = single_cell(txt);
0090 
0091 if nargout == 0
0092   for ii=1:length(txt)
0093     disp(txt{ii});
0094   end
0095 end
0096 
0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0098 
0099 function new_txt = single_cell(txt_field)
0100 
0101 new_txt = {};
0102 for ii=1:length(txt_field)
0103   if iscell(txt_field{ii})
0104     hh = single_cell(txt_field{ii});
0105     new_txt(end+1:end+length(hh)) = hh(1:end);
0106   else
0107     new_txt{end+1} = txt_field{ii};
0108   end
0109 end
0110 
0111 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003