Home > wafo > misc > wafoversion.m

wafoversion

PURPOSE ^

Wave Analysis for Fatigue and Oceanography version.

SYNOPSIS ^

wvers= wafoversion(dirnamein)

DESCRIPTION ^

 WAFOVERSION Wave Analysis for Fatigue and Oceanography version.
 
   CALL:  verstr =  wafoversion(dirname);
 
     verstr = string containing the WAFO version number.
    dirname = string containing the name of the directory
              If empty WAFOVERSION  displays the current WAFO version 
 
   WAFOVERSION extracts the version number from  the Contents.m file.
 
    Examples:
       wafoversion onedim      % returns the version of the ONEDIM directory
       wafoversion             % return current WAFO  version
 
  See also   version, ver, whatsnew, info, help.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

001 function wvers= wafoversion(dirnamein)
002 %WAFOVERSION Wave Analysis for Fatigue and Oceanography version.
003 %
004 %  CALL:  verstr =  wafoversion(dirname);
005 %
006 %    verstr = string containing the WAFO version number.
007 %   dirname = string containing the name of the directory
008 %             If empty WAFOVERSION  displays the current WAFO version 
009 %
010 %  WAFOVERSION extracts the version number from  the Contents.m file.
011 %
012 %   Examples:
013 %      wafoversion onedim      % returns the version of the ONEDIM directory
014 %      wafoversion             % return current WAFO  version
015 %
016 % See also   version, ver, whatsnew, info, help.
017 
018 %tested on: Matlab 5.3
019 %History:
020 % revised pab 11.11.1999
021 %  - made it more general
022 % by pab 11.10.1999
023 
024 if nargin<1 |isempty(dirnamein)
025   dirname=waforoot;
026 else
027   ind=find(dirnamein== filesep);
028   if length(ind)>0
029     dirname=dirnamein; % Assume that the complete path is given
030   else
031     if length(ind)==0
032       dirn=dirnamein;
033     elseif ind(end)< length(dirnamein)
034       dirn=dirnamein(ind(end)+1:end);
035     else
036       dirn=dirnamein(ind(end-1)+1:end-1);
037     end
038     p=path2cell(path);
039     for ix=1:length(p)
040       p{ix}=fliplr( p{ix});
041     end
042     ind2=strmatch(fliplr(dirn),p); % see if we can find directory in
043                                    % search path
044     if length(ind2)>1
045       disp(['There are two directories with the name: ' dirn])
046     end
047     if length(ind2)>0
048       dirname=fliplr(p{ind2(1)});
049     else
050       disp(['There is no directory with the name: ' dirn])
051       disp('in the search path')
052       disp('WAFO version returned instead')
053       dirname = waforoot;
054     end    
055   end
056 end
057 
058 file=fullfile(dirname ,'Contents.m');
059 fid=fopen(file,'rt');
060 if fid==-1,
061   file=fullfile(dirname ,'contents.m');
062   fid=fopen(file,'rt');
063   if fid==-1,
064     disp(['No Contents.m file in '  dirname])
065     disp('Version unknown')
066     wvers=[];
067     return
068   end
069 end
070 
071 lin=fgetl(fid); % H1 line
072 lin=fgetl(fid); % version line
073 fclose(fid);
074 % Look for Version
075 k = findstr('version',lower(lin));
076 if isempty(k),
077   disp(['Not correct format of Contents.m file in ', dirname])
078   disp('version number unknown')
079   wvers=[]; 
080   return
081 end
082 ind=diff(~isspace(lin));
083 blancstrtstp = find([0 abs(ind)] > 0.5); 
084 indbl= blancstrtstp( blancstrtstp > k); 
085 wvers=lin(indbl(2):indbl(3)-1);
086 
087 function c = path2cell(p)
088 %PATH2CELL Split path into cell array of strings.
089 %   PATH2CELL(PATH) returns a cell array of strings containing the
090 %   individual path elements.
091 
092 seps = [0 find(p==pathsep) length(p)+1];
093 
094 c = cell(length(seps)-1,1);
095 for i=1:length(seps)-1,
096   c{i} = p(seps(i)+1:seps(i+1)-1);
097   if c{i}(end) == ']',
098     c{i}(end) = [];
099   end
100 end
101 return
102

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003