ENVREST(III)                        3/3/76                         ENVREST(III)

NAME
	envsave, envrest - execute non-local goto

SYNOPSIS
	envsave(&envir);
	int envir;
	     .
	     .
	     .
	envrest(&envir);

DESCRIPTION
	Envsave saves an "environment pointer" in its argument, envir.
	A subsequent envrest with the same argument restores the environment
	that existed immediately AFTER the envsave call.  Envsave returns a
	value of 1; while a envrest appears to return from the corresponding
	envsave except that the returned value is 0.

	The routine that called envsave must still be active (i.e., must
	not have returned) when envrest is called.

	Envsave must be called with exactly one argument.

	Envsave and envrest are very similar in effect to setexit(III) and
	reset(III), in that they provide a means of resuming execution
	in a previously established environment and aborting a chain of
	procedure calls.  The major differences are:

	(1) Envsave and envrest permit saving more than one environment.

	(2) The returned values of envsave and envrest are different, so the
		return from envsave that saves the environment can be
		distinguished from subsequent envrests.

	(3) There may be more than one envrest call for one envsave, since
		the envrest restores the environment that existed AFTER,
		rather than before, the envsave call.


	Example:

		int saveloc;
		if (envsave(&saveloc))
		{       /* code to be executed on return from envsave */
			...
		}
		else
		{       /* code to be executed on return from envrest */
			...
		}
SEE ALSO
	reset(III)

AUTHORS
	Steve Zucker
	Keith Davis
