📄 dd_message.m
字号:
function dd_message(info, msg, varargin)% DD_MESSAGE Print formatted message%% DD_MESSAGE(INFO,MSG,PARAMS)%% Plot out a message MSG, formated like the string in fprintf and% parameters PARAMS.% It compares the value of INFO with the persistent parameter DD_INFO,% if DD_INFO>=info the message is printed. So the value info indicates% the urgency of the message: 1 is very urgent, while 5 is not really% urgent.% 1. pink ALARM% 2. red error% 3. yellow warning% 4. green message% 5. blue message%% If the persistent parameter DD_INFO does not exist, or is empty, it will be% set to the default value 5.% Copyright: D.M.J. Tax, D.M.J.Tax@prtools.org% Faculty EWI, Delft University of Technology% P.O. Box 5031, 2600 GA Delft, The Netherlandspersistent DD_INFO;if isempty(DD_INFO) DD_INFO = 5; if usejava('desktop') fprintf('DD_MESSAGE: Java desktop is running: Colors will not work!\n'); DD_INFO = -DD_INFO; endendif nargin<3 params = [];endif (nargin==1) & (isa(info,'double')) if usejava('desktop') & (DD_INFO>0) fprintf('DD_MESSAGE: Java desktop is running: Colors will not work!\n'); info = -info; end DD_INFO = sign(DD_INFO)*info; dd_message(info,'DD_MESSAGE: The current message level is set to %d.\n',info); returnendif nargin<1 if usejava('desktop') & (DD_INFO>0) fprintf('DD_MESSAGE: Java desktop is running: Colors will not work!\n'); DD_INFO = -DD_INFO; end dd_message(DD_INFO,'DD_MESSAGE: The current message level is %d.\n',abs(DD_INFO)); returnendif ~isa(info,'double') % when we forget the number, we use the default info = 3 varargin = [{msg} varargin]; msg = info; info = 3;endif abs(DD_INFO)>=info % Put some spaces in front for automatic indention: %str = repmat(' ',1,info); if (info<6) & (DD_INFO>0) if info<=0, intro = [char(27) '[1;',clrs(info,:),'m']; outro = [char(27) '[0;0m']; fprintf([intro,msg,outro],varargin{:}); end; clrs = ['31';'35';'32';'36';'34']; intro = [char(27) '[1;',clrs(info,:),'m']; outro = [char(27) '[0;0m']; fprintf([intro,msg,outro],varargin{:}); else %fprintf([str,msg],varargin{:}); fprintf(msg,varargin{:}); endendreturn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -