Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Suppose I got in a Dialog and wanted to not Return but Abort the computation. How could I do that?

Using Return[] the computation continues, and sometimes that implies getting inside countless other Dialogs of which it is not easy to go out without killing the kernel.

How do you handle those situations?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I use ExitDialog@Unevaluated@Abort[]

If your dialog is unhappily inside a CheckAbort you can go for exceptions like ExitDialog@Unevaluated@Throw["OOOUT", Unique[]] for example.

In this way, tools like TraceDialog become very useful. TraceDialog[code, Message] is something I use often, to see the Stack, the state, etc

Note that this only aborts one level. If you want 2 levels you could do ExitDialog@Unevaluated@ExitDialog@Unevaluated@Abort[]

For a general way to abort all dialogs of any level at once, one could do

Apply[Composition,
  ConstantArray[Function[i, ExitDialog@Unevaluated@i, HoldFirst], 
   DialogLevel[]]][Unevaluated@Abort[]]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.