function  countN = fprintN(fidN,varargin)

%FPRINTN -- Call FPRINTF for several files in parallel.
%
% countN = fprintN(fidN,varargin)
%
% FIDN is a vector of file ids, as opposed to FPRINTF which takes only
% one fid.  COUNTN is a vector of the same size. All other arguments
% are passed verbatim to FPRINTF.
%
% Example:
%  lfid=fopen('logfile.txt','w');fidN=[1 lfid];    % logfile & stdout
%  fprintN(fidN,'Subject %d, session %d.\n',12,1);
%  fclosef(lfid) ;
%
% See also FPRINTF.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.0 $  $Date: 2004/11/22 17:30 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ../utils_license.m

countN = zeros(size(fidN)) ;
N = length(fidN) ;

str = sprintf(varargin{:}) ;

for k = 1:N
   countN(k) = fprintf(fidN(k),'%s',str) ;
end

%--- Return COUNTN
%%%%% End of file FPRINTN.M