www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/mbcCheckForToolbox.m

    function [ok, errmsg] = mbcCheckForToolbox(strTlbxName, strLicense, strVer, doCheckOut)
%MBCCHECKFORTOOLBOX Check for existence of optional toolboxes
%
%   [OK, ERRMSG] = MBCCHECKFORTOOLBOX(STRTLBXNAME, STRLICENSE, STRVER)
%   checks to see whether the specified toolbox is available for use by
%   MBC. This function tests whether a license can be checked out and
%   checks to see whether the toolbox is on the path. If either of these
%   cases cannot be met, a suitable error message is returned.
%
%   [OK, ERRMSG] = MBCCHECKFORTOOLBOX(STRTLBXNAME, STRLICENSE, STRVER,
%   DOCHECKOUT) also tries to check out a license of the specified toolbox.
%
%   See also LICENSE, VER.

%   Copyright 2006-2009 The MathWorks, Inc.

if nargin < 4
    doCheckOut = false;
end
   
% Do license check
ok = logical(license('test', strLicense));
if ~ok
    errmsg = sprintf('%s%s%s', 'A license of the ', ...
        strTlbxName, ' Toolbox could not be found.');
    return
end

% Check to see that the toolbox is installed
ok = ~isempty(ver(strVer));
if ~ok
    errmsg = sprintf('%s%s%s', 'The ', strTlbxName , ...
        ' Toolbox is not on the path or not installed.');
    return
end

% Check to see that a license of a toolbox can be checked out
if doCheckOut
    [ok, errmsg] = license('checkout', strLicense);
    ok = logical(ok);
end