function dbmex(arg)
%DBMEX  Debug MEX-files (UNIX and VMS only).
%   DBMEX ON enables MEX-file debugging.
%   DBMEX OFF disables MEX-file debugging.
%   DBMEX STOP returns to debugger prompt.
%   DBMEX PRINT displays MEX-file debugging information.
%
%   DBMEX doesn't work on the Macintosh or the PC.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.10 $  $Date: 1997/11/21 23:31:30 $

if strncmp(computer,'PC',2) | strncmp(computer,'MAC',3)
  disp(sprintf(['DBMEX doesn''t work on the Macintosh or PC.  See the \n',...
        'MATLAB API Guide for details on how to debug mex files.']));

% in VMS you don't run MATLAB with the debugger
elseif any(getenv('MATLAB_DEBUG')) | isvms
    if nargin < 1, arg = 'on'; end
    if strcmp(arg,'stop')
        system_dependent(9);
    elseif strcmp(arg,'print')
        system_dependent(8,2);
    else
        system_dependent(8,real(strcmp(arg,'on')));
    end
else
    disp(' ')
    disp('In order to debug MEX-files, MATLAB must be run within a debugger.');
    disp(' ')
    disp('    To run MATLAB within a debugger start it by typing:');
    disp('           matlab -Ddebugger');
    disp('    where "debugger" is the name of the debugger you wish to use.');
    disp(' ')
end
