Reputation: 5228
When I enter
edit somenewfile.m
in my Matlab R2010a command window it gives me this error
??? Error using ==> edit at 57
Neither 'somenewfile' nor 'somenewfile.m' could be found.
On my other computer with R2012a at work, this same command works and creates a new file. Is there something different about 2010?
I tried fiddling around with edit.m for a little while, but I'm afraid I'm going to mess something up. Here is the part it is failing in
try
if (nargin == 0)
openEditor;
else
for i = 1:nargin
argName = translateUserHomeDirectory(strtrim(varargin{i}));
if isempty(argName)
openEditor;
else
checkEndsWithBadExtension(argName);
if ~openInPrivateOfCallingFile(argName)
if ~openOperator(argName)
if ~openWithFileSystem(argName, ~isSimpleFile(argName))
if ~openPath(argName)
showEmptyFile(argName);
end
end
end
end
end
end
end
catch exception
throw(exception); % throw so that we don't display stack trace
end
at ShowEmptyFile while looks like
%--------------------------------------------------------------------------
% Helper function that displays an empty file -- taken from the previous edit.m
% Now passes error message to main function for display through error.
function showEmptyFile(file)
errMessage = '';
errID = '';
% If nothing is found in the MATLAB workspace or directories,
% open a blank buffer only if:
% 1) the given file is a simple filename (contains no qualifying
% directories, i.e. foo.m)
% OR
% 2) the given file's directory portion exists (note that to get into
% this method it is implied that the file portion does not exist)
% (i.e. myDir/foo.m, where myDir exists and foo.m does not).
[path fileNameWithoutExtension extension] = fileparts(file);
if isSimpleFile(file) || (exist(path, 'dir') == 7)
% build the file name with extension.
if isempty(extension)
extension = '.m';
end
fileName = [fileNameWithoutExtension extension];
% make sure the given file name is valid.
checkValidName(fileName);
% if the path is empty then use the current working directory.
% else use the fully resolved version of the given path.
if (strcmp(path, ''))
path = pwd;
else
whatStruct = what(path);
path = whatStruct.path;
end
if (isempty(checkJavaAvailable) ...
&& com.mathworks.mde.editor.EditorOptions.getShowNewFilePrompt == false ...
&& com.mathworks.mde.editor.EditorOptions.getNamedBufferOption == ...
com.mathworks.mde.editor.EditorOptions.NAMEDBUFFER_DONTCREATE ...
&& com.mathworks.mde.editor.EditorOptions.getBuiltinEditor ~= 0)
[errMessage, errID] = showFileNotFound(file, false);
else
openEditor(fullfile(path,fileName));
end
else
[errMessage, errID] = showFileNotFound(file, false);
end
handleError(errMessage, errID);
Perhaps I have a bad edit.m? Or There was a setting that caused a new edit.m with code to throw an error? Any ideas?
Upvotes: 4
Views: 786
Reputation: 2125
I get the same error message in 2010a (line 57 of edit.m) if I edit a non-existent file after unchecking the following option:
File -> Preferences -> General -> Confirmation Dialogs -> Prompt when editing files that do not exist
With that it mind, it sounds like you don't have that option enabled?
Upvotes: 3