Hi all,
I've run into quite a pickle of a problem, I wonder if you've got it solved around the shop already somewhere.
I am trying to implement a function (say, 'gle.m') that opens the hyperlink provided by an error throwback directly, without me having to click on it with the mouse. I've tried several approaches, but since the error messages have different formats they are different to script.
Here's something that works from the command line:
msgText = getReport(MException.last,'extended','hyperlinks','on');
hyperlinks = regexp(msgText,'<a.*?/a>','match');
stringlit = regexprep(hyperlinks{end}(18:end),'\).+','\)');
eval(stringlit)
However, I cannot get it to work from a function!
Within a function, the following works:
lasterr = lasterror;
message = lasterr.message;
f = regexp(message,'File: \w+\.m','match');
if isempty(f)
return;
else
l = regexp(message,'Line: \d+','match');
c = regexp(message,'Column: \d+','match');
filename = f{1}(7:end);
fileloc = which(filename);
linenum = str2num(l{1}(7:end));
colnum = str2num(c{1}(9:end));
opentoline(fileloc,linenum,colnum)
end
However, it does not work for all error specifications.
This was turning out to be such an esoteric thing that I thought I might refer it to the experts. Any help appreciated.
Thanks!