Hello everybody,
I am trying to incorporate the diary off command within the Close RequestFcn expression, but I always get an error, here the details:
The idea: I open a figure and then start to record the command window. Then, if I manually close the figure by pressing on the x at the top right corner of the figure window, the command window displays a text and, at the same time, the diary stops recording.
Here is the code that does not work:
fig.CloseRequestFcn = @(~,~){fprintf('Script aborted\n'); close(fig, 'force'); diary('off')};
Here is the error:
Error using diary
Too many output arguments.
Error in Temp4>@(~,~){fprintf('Script aborted\n');close(fig,'force');diary('off')} (line 5)
fig.CloseRequestFcn = @(~,~){fprintf('Script aborted\n'); close(fig, 'force'); diary('off')};
Error while evaluating DestroyedObject CloseRequestFcn.
Note: if I remove "diary off" from the expression it works fine, but then I cannot delete write.txt file until I manually type "diary off" in the command window.
I hope I managed to explain myself. Really thank you in advance to everyone for the help!