Does checkcode return the status of the "Message indicator box", i.e. red/orange/green ?
Mostra commenti meno recenti
I search for an automatic way to find out if a file has a syntax error. That is, to find the same piece of information that the Code Analyzer indicates with red in the "Message indicator box" of the editor.
I took for granted that checkcode provides the information corresponding to the colors of the "Message indicator box".
Doc (R2012a) says:
[...] checkcode('filename') displays messages, sometimes referred to as
Code Analyzer messages, [...]
thus, I tried
info = checkcode( filespec );
and
info = checkcode( filespec, '-id' );
However, I cannot find the piece of information I need. isempty(info) equal to true indicates green, but, I cannot figure out how to find an indicator for red. (Not empty indicates red or orange.)
One way would be to have a list of the ID, which stands for errors.
5 Commenti
Walter Roberson
il 27 Nov 2012
I am not sure if I understand what you are asking? Are you asking it to analyze a file that definitely has syntax errors, but are finding that it returns emptyness ?
per isakson
il 27 Nov 2012
Image Analyst
il 30 Nov 2012
Sounds like he's trying to make his own mlint functionality. Not sure why since this functionality already exists in MATLAB.
Sean de Wolski
il 30 Nov 2012
It sounds like he'd like to be able to test whether a file has syntax errors before running it - sounds fair to me...
per isakson
il 30 Nov 2012
Modificato: per isakson
il 30 Nov 2012
Risposta accettata
Più risposte (1)
Sean de Wolski
il 30 Nov 2012
It looks like you could use try/catch and do an isempty check on the ME.stack:
%checkcodetest.m
X = [pi
for ii = 1:3
disp('hi')
end
And:
try;
checkcodetest;
catch ME;
end
Now to test:
isempty(ME.stack)
Categorie
Scopri di più su Background and Parallel Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!