Return all?

2 visualizaciones (últimos 30 días)
David
David el 23 de Mayo de 2011
I'm writing a custom input() function that, given the input 'quit', should stop all currently running functions and return to the command prompt. I'm running into an issue where a simple return isn't giving me the results I need, is there some alternative to this?
For example, I am writing a function that allows a user to pick an item from a list. I want my custom input() to immediately check for 'quit', and then I want the function that called it to further check for more conditions. The issue I'm running into is that the custom input() returns, and the other function keeps running. Of course, I can have input() return some trashy value like -6573.34, and then have my function check for that value, and return if it detects it. However, I feel like there should be a more elegant way. Is there a "Return all" function I'm missing?

Respuestas (1)

Walter Roberson
Walter Roberson el 23 de Mayo de 2011
No, this has been discussed in the past, and the result has been that there is no way to do this short of quitting MATLAB itself.
You should consider throwing an error() . If there happens to be a level that has a try/catch block that eats the error, then it either handles the error smoothly (in which case perhaps it was not appropriate for you to want to return all the way up) or the layer should be edited to rethrow that error if it is "eating" it instead of dealing with it appropriately.
  1 comentario
Matt Fig
Matt Fig el 23 de Mayo de 2011
That is what I seemed to remember on further reflection.

Iniciar sesión para comentar.

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by