function miopeneditor(varargin)
% MIOPENEDITOR  Open file in user specified editor


%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.3 $  $Date: 1998/06/18 18:29:47 $


% Now determine which editor to run
% Assume builtin editor to begin with
builtinEd = 1;

% Get the MATLAB editor preference.
% Note: On UNIX, the user's editor preference is read by miedit
% from the .Xdefaults file.
if strncmp(computer, 'PC', 2),
   if getprofl('Matlab Settings', 'Built-in Editor', '1', 'matlab.ini') == '0'
      editor = getprofl('Matlab Settings', 'Editor Pref', 'medit.exe', 'matlab.ini');
      builtinEd = 0;
   end
end

if isvms, 
  builtinEd = 0;
  edt(varargin{:});
  return;
end;

if builtinEd == 1,
   % Use the built-in editor
   if nargin == 0,
      system_dependent('miedit','editor');
   else
      system_dependent('miedit','editor', varargin{:});
   end
else
   % User-specified editor
   if nargin == 0,
      eval(['!"' editor '" &'])
   else
      eval(['!"' editor '" "' varargin{1} '" &'])
   end
end
