Resuming from "keyboard" command?

66 visualizaciones (últimos 30 días)
Giuseppe Antonio
Giuseppe Antonio el 19 de Nov. de 2019
Editada: Jan el 28 de Feb. de 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 comentarios
Giuseppe Antonio
Giuseppe Antonio el 22 de Nov. de 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 el 2 de Nov. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 22 de Nov. de 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 comentarios
Steven Lord
Steven Lord el 27 de Feb. de 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 el 27 de Feb. de 2023
Editada: Jan el 28 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by