No BSD License  

Highlights from
htmltool

htmltool

by

 

The HTML Toolbox (HT) stores various crosslink information about Matlab programs using HTML.

FIL_srh(mfilename,typ)
function C = FIL_srh(mfilename,typ)
% C = FIL_srh(mfilename,typ)
% Returns the names of files read or written by
% a selected m-file
%
% INPUT PARAMETERS
%
% mfilename  = the name of m-file WITHOUT the .m extension
% type       = 1-> mat-files (look for the "load" command)
%              2-> print-files (look for print -dxxxx command)
%              3-> save-files (look for "save" command)
%
% OBS! Only one command per line in m-file!
%
% OUTPUT PARAMETER
%
% C          = a string matrix where each row contains the name of the
%              specific file type. Extensions will be included as they
%              are specified in the loading/saving/printing commands.
%
% Copyright (c) 1996 B.K. Alsberg
%
 
fid = fopen([mfilename,'.m'],'r');
fnp =[''''];
% The maximum length of each filename:
n=80;
C =[]; cc ='x';

%%%%%%%%%%%% Look for LOAD   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if typ ==1,
  k=1;
  stop =1;
  %%% This part locates the word ``load'' %%%%%%%%%%
  while feof(fid)~=1,
    out1 = fgetl(fid);
    out1 = [out1 blanks(1)];

    % We skip all comment lines:
    cc = strtok(out1);
    % need to check for cases of no string and eof: %%%%%%
    if length(cc) < 1, 
     cc='x';
    end;
    if cc(1) == '-1',
      cc(1) = '%';
    end;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if cc(1) ~= '%',
      a = findstr([out1 blanks(5)],'load');
%      keyboard
%      pause
      if length(out1) >= a+4,
       if length(a) >= 1 & out1(a+4) == ' ',
          s = deblank(out1(a+4:length(out1)));
          g = strtok(s);
          if k ==1,
            C = zeros(1,n);
          end;
          if length(g) >=1,  
            C(k,1:length(g))=g;
            k=k+1;
          end;
       end; %%%%%%%%% if length(a) >= 1 & out1(a+4) == ' ', %%%%%%%%%
      end; %%%%%%%%%% if length(out1) >= a+4, %%%%
   end; %comment line check
  end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

frewind(fid);

elseif typ == 2,

%%%%%%%%%%%% Look for print   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  k=1;
  %%% This part locates the word ``print'' %%%%%%%%%%
  while feof(fid)~=1,
    out1 = fgetl(fid);
    % We skip all comment lines:
    cc = strtok(out1);
    % need to check for cases of no string and eof: %%%%%%
    if length(cc) < 1, 
     cc='x';
    end;
    if cc(1) == '-1',
      cc(1) = '%';
    end;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if cc(1) ~= '%',
     a = findstr([out1 blanks(5)],'print');

     if length(a) >= 1 & out1(a+5) == ' ',
      s = deblank(out1(a+5:length(out1)));
      G = wrdfnd(s);
      gstr1 = [G(1,:) blanks(1)];
      gstr2 = [G(2,:) blanks(1)];

      ext = prnt_ext(gstr1);
      g = [deblank(gstr2),ext];
      if k ==1,
        C = zeros(1,n);
      end;
       if length(g) >=1,  
        C(k,1:length(g))=g;
        k=k+1;
       end;
     end;
  end; %comment check
  end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

frewind(fid);
elseif typ == 3,


%%%%%%%%%%%% Look for save   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  k=1;
  %%% This part locates the word ``save'' %%%%%%%%%%
  while feof(fid)~=1,
    out1 = fgetl(fid);
    % We skip all comment lines:
    cc = strtok(out1);
    % need to check for cases of no string and eof: %%%%%%
    if length(cc) < 1, 
     cc='x';
    end;
    if cc(1) == '-1',
      cc(1) = '%';
    end;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if cc(1) ~= '%',
     a = findstr([out1 blanks(5)],'save');
     if length(a) >= 1 & out1(a+4) == ' ',
      s = deblank(out1(a+4:length(out1)));
      g = strtok(s);
      if k ==1,
        C = zeros(1,n);
      end;
       if length(g) >=1,  
        C(k,1:length(g))=g;
        k=k+1;
       end;
     end;
   end; %comment check
  end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end; %if typ

fclose(fid);

Contact us