home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / GENERAL.DI$ / VER.M < prev    next >
Encoding:
Text File  |  1993-04-27  |  3.3 KB  |  120 lines

  1. function ver(arg)
  2. %VER    MATLAB version number.
  3. %    VER displays the current MATLAB and toolbox version numbers.
  4. %    VER(TBX) displays the current version information for the
  5. %    toolbox specified by the string TBX.
  6.  
  7. %       Copyright (c) 1984-93 by The MathWorks, Inc.
  8.  
  9. p = path;
  10. pathsep = ':';
  11. filesep = '/';
  12. c = computer;
  13. sys = 'u';
  14. if strcmp(c(1:2),'PC')
  15.    pathsep = ';';
  16.    filesep = '\';
  17.    sys = 'p';
  18. elseif strcmp(c(1:2),'MA')
  19.    pathsep = ';';
  20.    filesep = ':';
  21.    sys = 'm';
  22. elseif ~isunix   % VMS
  23.    pathsep = ',';
  24.    filesep = '.';
  25.    sys = 'v';
  26. end
  27. seps = find(p == pathsep);
  28. first = [1 seps+1];
  29. last = [seps-1 length(p)];
  30. n = length(first);
  31. if nargin > 0
  32.    larg = length(arg);
  33.         if strcmp('matlab',lower(deblank(arg)))
  34.             disp(['MATLAB Version ',version]);
  35.             if sys == 'v' | sys == 'u'
  36.                disp(['MATLAB Server Hostid: ',hostid])
  37.             end
  38.             disp(['MATLAB Site Identification Number: ',siteid]);
  39.             return
  40.         end
  41.    for i=1:n
  42.       pp = p(first(i):last(i));
  43.       lp = length(pp);
  44.       if lp >= larg
  45.          if strcmp(arg,pp(lp-larg+1:lp))
  46.             file = [pp filesep 'Contents.m'];
  47.             if exist(file) == 2
  48.                c = computer;
  49.                if c(1:2) == 'PC'
  50.                   fp = fopen(file,'rb');
  51.                else
  52.                   fp = fopen(file,'r');
  53.                end
  54.                s = [fgetl(fp) '  '];
  55.                s1 = [fgetl(fp) '  '];
  56.                s(1:2) = [];
  57.                s1(1:2) = [];
  58.                disp([s '  ' s1])
  59.                fclose(fp);
  60.             else
  61.                disp(['No Contents.m file for ' pp])
  62.             end
  63.          end
  64.       end
  65.    end
  66.    return
  67. end
  68. % before we do this, we want to strip off the MATLAB portion of the
  69. % path because we don't want to see all the separate Contents.m files
  70. % for the MATLAB toolbox --- at the moment, there are 20 MATLAB directories.
  71. disp(['MATLAB Version ',version]);
  72. if sys == 'v' | sys == 'u'
  73.    disp(['MATLAB Server Hostid: ',hostid])
  74. end
  75. disp(['MATLAB Site Identification Number: ',siteid]);
  76. for i=1:n
  77.    pp = p(first(i):last(i));
  78. % don't do ones with toolbox/matlab/*
  79. % or toolbox/local (or PC, VMS, or MAC equivs)
  80. % peel apart name
  81.    mlorloc = 0;
  82. % find fileseps within this
  83.    filind = find(pp == filesep);
  84.    filind = [0 ; filind(:)];
  85.    nsep = length(filind);
  86.    if nsep == 1
  87.       mlorloc = strcmp('local',lower(pp)); % special VMS case, I think
  88.    else
  89. % check for toolbox/local last
  90.       last2 = pp(filind(nsep-1)+1:length(pp));
  91.       loc = strcmp(lower(last2),['toolbox' filesep 'local']);
  92.       ml = 0;
  93.       if nsep > 2
  94.          last3 =  pp(filind(nsep-2)+1:filind(nsep)-1);
  95.          ml = strcmp(lower(last3),['toolbox' filesep 'matlab']);
  96.       end
  97.       mlorloc = ml | loc;
  98.    end
  99. % find file separators
  100.    if ~mlorloc  % not toolbox/matlab/ or local
  101.       file = [pp filesep 'Contents.m'];
  102.       if exist(file) == 2
  103.          c = computer;
  104.          if c(1:2) == 'PC'
  105.             fp = fopen(file,'rb');
  106.          else
  107.             fp = fopen(file,'r');
  108.          end
  109.          s = [fgetl(fp) '  '];
  110.          s1 = [fgetl(fp) '  '];
  111.          s(1:2) = [];
  112.          s1(1:2) = [];
  113.          disp([s '  ' s1])
  114.          fclose(fp);
  115.       else
  116.          disp(['No Contents.m file for ' pp])
  117.       end
  118.    end
  119. end
  120.