Resuming from "keyboard" command?
42 views (last 30 days)
Show older comments
I'm using the "keyboard" command to stop the execution in a nested (callback) function (which is triggered by a pushbutton) in order to make the user able to modify its workspace.
function myFunc()
...
function myNestedFunc(h,~)
load('myMatFile.mat','myGraph');
openvar myGraph.Edges;
keyboard;
end
end
The problem is, that to exit from the debug mode, the user should run "dbcont" in the Command Window. But I want to resume as soon as he finished to edit the variable.
If I try to write another callback function like this:
function myFunc()
...
function resume(h,~)
dbcont;
end
end
I get the error "Debug commands only allowed when stopped in debug mode".
Is there a way to resume from "keyboard" without forcing the user to manually enter "dbcont" in the Command Window?
3 Comments
Jan
on 2 Nov 2022
@Giuseppe Antonio: Please open a new thread for a new question. Show the relevant part of the code and a copy of the complete error message.
Combining eval with debugging sounds like a wierd program design. I'm not surprised that such programming constructs are fragile. Do not use such crutches for productive code.
Answers (1)
Jan
on 22 Nov 2019
Using debug commands for an interaction with the user is a really bad design. A dynamic modification of the workspace is very fragile.
Resuming the debug mode througth another callback is strange also. Actually you should be able to check, if Matlab is in debug mode currently, but starting another callback while stopped in debug mode in another one, is at least confusing. Even including the dbcont in a try/catch block is not a smart solution - but worth to try for reasons of experiences.
Create a clean GUI for user interactions. Use the debugging methods only for debugging.
5 Comments
Steven Lord
on 27 Feb 2023
I think you've opened a separate question for your specific use case, correct? In that case let's continue the discussion of that use case in that question rather than here, to avoid potential duplication of information and effort.
Jan
on 27 Feb 2023
Edited: Jan
on 28 Feb 2023
@Robert Scott: "There is no alternative method suggested." - Surely I've suggested to create a clean, stable and user-friendly GUI. I do not suggest methods, with which the programmer drills a hole in his own knee, and in the knees of the users of the code. If you really want this, post your own solution. You cannot claim, that I write, what you want to hear.
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!