I like the spirit of what you are trying to do, but I think this probably goes against the general programming patterns in Matlab. As you correctly state, the goal of the end semicolon is to suppress the printing of return values. Trying to make it turn on your other function may well require some deep hacking and ugly hard code. The standard way to implement what you are describing is with the arguments of the name-value pair of the property. For example, the Matlab optimization set has a property 'Display'that can be set to various values ββto indicate the desired level of detail (see optimset).
, mint, mlintmex mtree - . , mlint, , "Terminate statement with semicolon to suppress output" (. MatlabCental) t , .
, , , . , , , . , , , ....
st = dbstack('-completenames'); % M-file of caller and line number
caller = st(2);
str = mlint('-lex',caller.file); % Struct containing parsed data
isSemicolon = false; % Assume no semicolon
for i = 1:length(str)
% Find end-of-line corresponding to function call
c = strsplit(str(i).message,'/');
if str2double(c{1}) == caller.line && strcmp(c{2}(end-5:end-1),'<EOL>')
% Check for comments
j = i-1;
if ~isempty(strfind(str(j).message,'%'))
j = j-1;
end
% Check for semicolon
if strcmp(str(j).message(end-2),';')
isSemicolon = true; % Semicolon found
break;
end
end
end
, , , .