function fmfiles(varargin)
% FMFILES Find missing files
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The function searches files declared in varagin list of items in working
% directory, on matlabpath and a system path. The items are separated by
% comas. Files not found will be displayed in an error message output.
% If no function is missing, no error interruption is present.
% The function can be used either from a program or from Command Window.
%
% List of input arguments contains items in arbitrary order:
% name file name (string) with no extension = m-file name,
% name.ext file name with extension can be m-file or another name,
% {name,IdNo} a cell containing name without or with extension '.m',
% idetification number of the file in File Exchande.
% Example:
% fmfiles('inp','fig.m',{'ffpath',22501},'myprog.exe');
% Miroslav Balda
% miroslav (AT) balda DOT cz
% 2009-01-24 v 1.0
if nargin<1, help absentfiles, end
Mf = '';
Xf = '';
Sf = '';
miss = false;
for k = 1:length(varargin)
item = varargin{k};
if iscell(item)
if ~exist(item{1},'file')
miss = true;
Xf = [Xf,' FEX Id',sprintf('%6d',item{2}),' ',item{1},'\n'];
end
else
[pth,name,ext] = fileparts(item);
if isempty (ext) || strcmp(ext,'.m')
if ~exist(name,'file')
miss = true;
Mf = [Mf,[' ',name,'.m\n']];
end
else
if ~exist('ffpath','file')
miss = true;
Xf = [Xf,' FEX Id 22501 ffpath\n'];
else % skips test of item if ffpath does not exist
if isempty(ffpath(item))
miss = true;
Sf = [Sf,[' ',item,'\n']];
end
end
end
end
end % k
if miss
txt = {};
if ~isempty(Mf)
txt = {[txt{:}, sprintf(['Missing M-function(s):\n', Mf])]};
end
if ~isempty(Xf)
txt = [txt, sprintf(['Download function(s) from File Exchange:\n', Xf])];
end
if ~isempty(Sf)
txt = {[txt{:}, sprintf(['Place file(s)\n',Sf,...
'in the working directory or on the system path!\n'])]};
end
error(txt{:});
end