Ofprintf

PURPOSE ^

% function for printing information on the command window (based on fprintf)

SYNOPSIS ^

function nbT = Ofprintf(varargin)

DESCRIPTION ^

% function for printing information on the command window (based on fprintf)
% L. LAURENT -- 12/09/2016 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% function for printing information on the command window (based on fprintf)
0002 %% L. LAURENT -- 12/09/2016 -- luc.laurent@lecnam.net
0003 
0004 % sources available here:
0005 % https://bitbucket.org/luclaurent/optigtest/
0006 % https://github.com/luclaurent/optigtest/
0007 
0008 % optiGTest - set of testing functions    A toolbox to easy manipulate functions.
0009 % Copyright (C) 2018  Luc LAURENT <luc.laurent@lecnam.net>
0010 %
0011 % This program is free software: you can redistribute it and/or modify
0012 % it under the terms of the GNU General Public License as published by
0013 % the Free Software Foundation, either version 3 of the License, or
0014 % (at your option) any later version.
0015 %
0016 % This program is distributed in the hope that it will be useful,
0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 % GNU General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU General Public License
0022 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 
0024 
0025 function nbT = Ofprintf(varargin)
0026 
0027 %adding text in front of the original text
0028 txtAdd='optiGTest';
0029 
0030 %check if the first argument is a double (corresponding to a file id)
0031 if isa(varargin{1},'double')
0032     %argOk=varargin{2:end};
0033     %use the classical fprintf function
0034     nbT=fprintf(varargin{:});
0035 else
0036     argOk=varargin;   
0037     
0038     %convert all inputs to a string
0039     str = sprintf(argOk{:});
0040     
0041     %find new lines
0042     strSplit=regexp(str,'\n','split');
0043     
0044     % display text and adding new keyword
0045     nbT=0;
0046     for itS=1:numel(strSplit)
0047         if itS==numel(strSplit)&&isempty(strSplit{itS})
0048         else
0049             txtD=[ txtAdd ' | ' strSplit{itS}];
0050             nbytes=fprintf(txtD);
0051             nbT=nbT+nbytes;
0052         end
0053         if itS<numel(strSplit)
0054             nbytes=fprintf('\n');
0055             nbT=nbT+nbytes;
0056         end
0057     end
0058 end
0059 end

Generated on Tue 28-May-2019 16:00:34 by m2html © 2005