------------------------------------------------------------------------ OUT Prints screen messages with some layout The verbosity is determined by the general Atmlab setting VERBOSITY. This function is called by setting a report level and if this level is <= than VERBOSITY, the message is displayed. Otherwise it is ignored. The function puts a frame around the text. The width of this frame is set by the general setting SCREEN_WIDTH. To begin a frame put s=1, to end s=-1. A braking line is obtained by s=0. An example. The command out(1,1);out(1,'Heading');out(1,0);out(2,'Some text');out(1,-1) gives /--------------------------------------------------------------\ | Heading | |--------------------------------------------------------------| | Some text | \--------------------------------------------------------------/ The function can also be used to determine if figures etc. shall be produced (the last format example). The vertical and horisontal frame lines can be removed by setting the optional argument *lines* to 0. The output can also be directed to a file by using the optional argument *fid*. Note that you can write to several files and the screen by making *fid* a vector. The screen has identifier 1. FORMAT: out( level, s [, fid, lines] ) or do_output = out( level ) OUT: do_output Boolean. True if level <= VERBOSITY IN: level Report level for the message. This can be specified for each entry in *fid*. Default is 0. This values is also applied if *level* is shorter than *fid*. s Message. Can be a string matrix (see str2mat). If s is an integer, different vertical lines are produced (see above). OPT fid Vector with file identifiers. Default is 1, which is standard output (screen). For zero verbosity set to []. lines Flag to draw vertical and horisontal frame lines. ------------------------------------------------------------------------
0001 %------------------------------------------------------------------------ 0002 % OUT Prints screen messages with some layout 0003 % 0004 % The verbosity is determined by the general Atmlab setting 0005 % VERBOSITY. This function is called by setting a report level 0006 % and if this level is <= than VERBOSITY, the message is 0007 % displayed. Otherwise it is ignored. 0008 % 0009 % The function puts a frame around the text. The width of this 0010 % frame is set by the general setting SCREEN_WIDTH. To begin a 0011 % frame put s=1, to end s=-1. A braking line is obtained by s=0. 0012 % 0013 % An example. The command 0014 % 0015 % out(1,1);out(1,'Heading');out(1,0);out(2,'Some text');out(1,-1) 0016 % 0017 % gives 0018 % 0019 % /--------------------------------------------------------------\ 0020 % | Heading | 0021 % |--------------------------------------------------------------| 0022 % | Some text | 0023 % \--------------------------------------------------------------/ 0024 % 0025 % The function can also be used to determine if figures etc. 0026 % shall be produced (the last format example). 0027 % 0028 % The vertical and horisontal frame lines can be removed by setting 0029 % the optional argument *lines* to 0. 0030 % 0031 % The output can also be directed to a file by using the optional 0032 % argument *fid*. Note that you can write to several files and 0033 % the screen by making *fid* a vector. The screen has identifier 1. 0034 % 0035 % FORMAT: out( level, s [, fid, lines] ) 0036 % or 0037 % do_output = out( level ) 0038 % 0039 % OUT: do_output Boolean. True if level <= VERBOSITY 0040 % IN: level Report level for the message. This can be specified 0041 % for each entry in *fid*. Default is 0. This values is 0042 % also applied if *level* is shorter than *fid*. 0043 % s Message. Can be a string matrix (see str2mat). 0044 % If s is an integer, different vertical lines are 0045 % produced (see above). 0046 % OPT fid Vector with file identifiers. Default is 1, which 0047 % is standard output (screen). For zero verbosity 0048 % set to []. 0049 % lines Flag to draw vertical and horisontal frame lines. 0050 %------------------------------------------------------------------------ 0051 0052 % HISTORY: 040907 Copied from AMI and modified to Atmlab by Patrick 0053 % Eriksson, who also made AMI version. 0054 0055 0056 function do_output = out( varargin ) 0057 % 0058 [level,s,fid,lines] = optargs( varargin, {0,0,1,true} ); 0059 %&% 0060 %&% 0061 %- Check input %&% 0062 % %&% 0063 rqre_nargin( 1, nargin ); %&% 0064 % %&% 0065 rqre_alltypes( level, {@isvector,@iswhole} ); %&% 0066 rqre_datatype( s, {@ischar,@iswhole} ); %&% 0067 rqre_alltypes( fid, {@isnumeric,@isvector} ); %&% 0068 rqre_datatype( lines, @isboolean ); %&% 0069 % %&% 0070 atmlab( 'require', {'VERBOSITY','SCREEN_WIDTH'} ); %&% 0071 0072 0073 if isempty(fid) 0074 return 0075 end 0076 0077 if length(fid) > 1 0078 for i = 1 : length(fid) 0079 if length(level) >= i 0080 out( level(i), s, fid(i), lines ); 0081 else 0082 out( 0, s, fid(i), lines ); 0083 end 0084 end 0085 return 0086 end 0087 0088 verbosity = atmlab( 'VERBOSITY' ); 0089 ncols = atmlab( 'SCREEN_WIDTH' ); 0090 0091 if level <= verbosity 0092 do_output = 1; 0093 else 0094 do_output = 0; 0095 return 0096 end 0097 0098 0099 if nargin == 1 0100 return; 0101 end 0102 0103 if level == 0 0104 level = 1; 0105 end 0106 0107 if ischar(s) 0108 0109 for i = 1:size(s,1) 0110 0111 if lines 0112 fprintf(fid,'| '); 0113 end 0114 0115 %Indention 0116 for j = 1:(level-1) 0117 fprintf(fid,' '); 0118 end 0119 0120 fprintf(fid,'%s',s(i,:)); 0121 0122 for j = 1:(ncols-length(s)-(level-1)*2-3) 0123 fprintf(fid,' '); 0124 end 0125 0126 if lines 0127 fprintf(fid,'|\n'); 0128 else 0129 fprintf(fid,'\n'); 0130 end 0131 end 0132 0133 0134 else 0135 0136 %=== Start line 0137 if s > 0 0138 if lines 0139 fprintf(fid,'\n/'); 0140 for j = 1:(ncols-2) 0141 fprintf(fid,'-'); 0142 end 0143 fprintf(fid,'\\\n'); 0144 else 0145 fprintf(fid,'\n'); 0146 end 0147 0148 %=== Brake line 0149 elseif s == 0 0150 if lines 0151 fprintf(fid,'|'); 0152 for j = 1:(ncols-2) 0153 fprintf(fid,'-'); 0154 end 0155 fprintf(fid,'|\n'); 0156 else 0157 fprintf(fid,'\n'); 0158 end 0159 0160 %=== End line 0161 else 0162 if lines 0163 fprintf(fid,'\\'); 0164 for j = 1:(ncols-2) 0165 fprintf(fid,'-'); 0166 end 0167 fprintf(fid,'/\n'); 0168 else 0169 fprintf(fid,'\n'); 0170 end 0171 end 0172 0173 end