MATLAB Answers

Maheen
0

What does parse error basically mean?

Asked by Maheen
on 5 Jul 2014
Latest activity Answered by Image Analyst
on 5 Jul 2014
I just wanted to clarify in very layman terms what is a parse error?

  0 Comments

Sign in to comment.

2 Answers

Answer by James Tursa
on 5 Jul 2014

When did you get this error? In general, the term "parsing" refers to MATLAB reading an m-file (script or function) and translating it into an internal code that it stores in memory. It is this "parsed" file in memory that is actually run when you execute the code.

  0 Comments

Sign in to comment.


Answer by Image Analyst
on 5 Jul 2014

You might have some code that throws an exception (generates an error) like this:
try
% Some code that might generate an error.
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
The error here is a string in ME.message. Parse it means that you might look at the error and try to recognize certain words and take action based upon what you find. For example you might have an error that says this:
Error using imread (line 349)
File "sss.dd" does not exist.
and you might want to do some particular thing, like alert the programmer that the file doesn't exist and to make sure the folder is prepended to the filename
if ~isempty(strfind('does not exist') ) % Parse error message
warndlg(..............

  0 Comments

Sign in to comment.