Re: Looking for Stop
- To: mathgroup at smc.vnet.net
- Subject: [mg93140] Re: Looking for Stop
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Tue, 28 Oct 2008 04:54:52 -0500 (EST)
- References: <firstname.lastname@example.org>
carlos at colorado.edu wrote:
> Mathematica has two termination commands:
> Abort interrupts a computation
> Exit or Quit returns control to OS
> I use Exit in some course-distributed application programs
> that detect an irrecoverable error requiring user intervention
> and program changes. This has an undesirable side effect:
> all cells containing support modules have to be reinitialized.
> Abort does not have that effect; however it doesnt stop
> execution of whatever follows.
> Is there a command "in between" that stops kernel
> execution but leaves cells initialized? Constraint:
> it has to work with versions >=4.1. I looked for
> Stop but there isnt such a thing under versions 4 or 5.
> Note: played with Throw and Catch, but this only terninates
> the evaluation of whatever is inside Catch[...]. Not too
> useful for big programs. I also tought to place a forward
> Goto to a Label: at the end of the main program;
> that doesnt work either since a label is not visible
> until it is reached.
> What happens if the code hits Break and there is no enclosing
> Do, For or While? Need to check that possibility.
Abort does stop an evaluation immediately, but it does not stop the
item by item evaluation of the contents of a notebook - just the current
evaluation. Compare for example:
The first case consists of four separate evaluations (even if they lie
within one cell) whereas the second is just one larger evaluation. The
second one aborts in the desired way.
In general it is best (for many reasons) to structure your code as a
series of variable/function definitions followed by one call to a
function that starts the code running. If you do that, Abort will do
what you require.
Prev by Date:
Re: Re: Is there a simple way to transform 1.1 to 11/10
Next by Date:
Understanding the number of digits given by RealDigits
Previous by thread:
Re: Looking for Stop
Next by thread: