Resuming from "keyboard" command?

71 visualizzazioni (ultimi 30 giorni)
Giuseppe Antonio
Giuseppe Antonio il 19 Nov 2019
Modificato: Jan il 28 Feb 2023
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 Commenti
Giuseppe Antonio
Giuseppe Antonio il 22 Nov 2019
If I use the eval function, I get the error "Debug commands only allowed when stopped in debug mode". I don't know if this depends on the MATLAB versions, but I must use it.
Any suggestions on how to overcome this problem?
Jan
Jan il 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.

Accedi per commentare.

Risposte (1)

Jan
Jan il 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 Commenti
Steven Lord
Steven Lord il 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
Jan il 27 Feb 2023
Modificato: Jan il 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.

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by