Home > source > @penlab > print_opts.m

print_opts

PURPOSE ^

print all options from the object via obj.print() and add a flag if it is

SYNOPSIS ^

function [errmsg] = print_opts(obj, minlev, maxlev)

DESCRIPTION ^

 print all options from the object via obj.print() and add a flag if it is
 a default setting or changed by user from obj.opts
 If minlev/maxlev specified, print only on these levels, if not all (0-Inf)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % print all options from the object via obj.print() and add a flag if it is
0002 % a default setting or changed by user from obj.opts
0003 % If minlev/maxlev specified, print only on these levels, if not all (0-Inf)
0004 function [errmsg] = print_opts(obj, minlev, maxlev)
0005   
0006   errmsg = [];
0007   if (nargin<=1)
0008     minlev=0;
0009     maxlev=Inf;
0010   elseif (nargin<=2)
0011     maxlev=Inf;
0012   end
0013 
0014   errmsg=obj.print(minlev,maxlev,'All option settings (* = set by user):');
0015 
0016   % create an array of flags if the option is coming from user or as default
0017   optnames = fieldnames(obj.allopts);
0018   usrset = isfield(obj.opts, optnames);
0019   no_opts=length(optnames);
0020 
0021   for i=1:no_opts
0022     fld=obj.allopts.(optnames{i});
0023     if (usrset(i))
0024       flag='*';
0025     else
0026       flag=' ';
0027     end
0028     if (isempty(fld))
0029       str='[not used]';
0030     elseif (isnumeric(fld))   
0031       str=sprintf('%g ',fld);  % this will work even with arrays
0032     elseif (ischar(fld))
0033       str=fld;
0034     else
0035       str='[other type, in use]'
0036     end
0037     errmsg=obj.print(minlev,maxlev,'  %-20s %s: %s',optnames{i},flag,str);
0038   end
0039

Generated on Mon 26-Aug-2019 10:22:08 by m2html © 2005