function path = mauifindexe(name)
%MAUIFINDEXE Return the absolute pathname to a MAUI executable.
%   NAME is the basename of the executable.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.6 $  $Date: 1998/05/28 19:51:15 $

if nargin == 0
    error('You must provide the name of a maui executable.');
    path = 0
else
    binStr = [filesep 'bin'];

    if strncmp(computer,'PC',2)
        binDir = [binStr filesep 'nt'];
        name = [name '.exe'];
        rootdir = matlabroot;
    else
        binDir = [binStr filesep lower(computer)];
        name(1,1) = upper(name(1,1));
        rootdir = getenv('MWE_USER_SANDBOX');
        if isempty(rootdir)
          rootdir = matlabroot;
        end
    end

    % figure out which dir the Maui executable lives in
    if(exist([rootdir binDir]) == 7)
        toolsdir = [rootdir binDir];
    else
        toolsdir = [rootdir binStr];
    end

    % check for the existence of the executable
    if exist([toolsdir filesep name]) == 2
        path = [toolsdir filesep name];
    else
        path = 0;
    end
end


