/*****************************************************************************

	ExeEW()

	This function executes an EW command.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefTeco.h"		/* define general identifiers */
#include "DefChars.h"		/* define identifiers for characters */

extern	DEFAULT	BldStr();	/* build a string */
extern	DEFAULT	ZOpOut();	/* open output file */

EXTERN	BYTE	CmdMod;		/* command modifiers flags for @, :, etc. */
EXTERN	DEFAULT	CurOut;		/* index of current output stream in OFiles */
EXTERN	WORD	EStBot;		/* expression stack bottom */
EXTERN	WORD	EStTop;		/* expression stack top */
EXTERN	char	FBfBeg[];	/* beginning of file specification buffer */
EXTERN	char	*FBfEnd;	/* end of file specification buffer */
EXTERN	char	*FBfPtr;	/* pointer into file specification buffer */


DEFAULT ExeEW()			/* execute an EW command */
{
#if DEBUGGING
DbgInd+=2;if(DbgLvl>=1){DbgMsg();DbgDBf("ExeEW: called.\015\012");DbgROf();}
#endif
	if (BldStr(FBfBeg, FBfEnd, &FBfPtr) == FAILURE)
#if DEBUGGING
{if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeEW: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
#if DEBUGGING
}
#endif
	if (FBfPtr == FBfBeg)			/* if it's EW$ */
		CurOut = POUTFL;
	else					/* else (it's EWxxxx$) */
		if (ZOpOut(CurOut) == FAILURE)	/* open output file */
#if DEBUGGING
{if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeEW: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
			return(FAILURE);
#if DEBUGGING
}
#endif
	CmdMod = '\0';				/* clear modifiers flags */
	EStTop = EStBot;			/* clear expression stack */
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeEW: returning SUCCESS.\015\012");DbgROf();}DbgInd-=2;
#endif
	return(SUCCESS);
}
