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

	ExeFN()

	This function executes an FN command.

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

#include "ZPort.h"		/* define portability identifiers */
#include "DefError.h"		/* define identifiers for error messages */
#include "DefTeco.h"		/* define general identifiers */

extern	VOID	ErrMsg();	/* display an error message */
extern	DEFAULT	Replac();	/* replace a string */

EXTERN	BYTE	CmdMod;		/* command modifiers flags for @, :, etc. */
EXTERN	char	*CBfPtr;	/* pointer into command string */
EXTERN	WORD	SrcTyp;		/* search type (S, N, _ or E_) */


DEFAULT ExeFN()			/* execute an FN command */
{

#if DEBUGGING
DbgInd+=2;if(DbgLvl>=1){DbgMsg();DbgDBf("ExeFN: called.\015\012");DbgROf();}
#endif

/* The command m,nFN is illegal: the user should use m,nFC */

	if (CmdMod & MARGIS)			/* if it's m,nFN */
		{
		ErrMsg(ERR_ILL, "m,nFN");	/* illegal command "m,nFN" */
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeFN: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
		}

	if (CmdMod & DCOLON)			/* if it's ::FN */
		{
		ErrMsg(ERR_ILL, "::FN");	/* illegal command "::FN" */
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeFN: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
		}

	SrcTyp = N_SEARCH;
	if (Replac() == FAILURE)
#if DEBUGGING
{if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeFN: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
#if DEBUGGING
}
#endif

	CmdMod = '\0';				/* clear modifiers flags */
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ExeFN: returning SUCCESS.\015\012");DbgROf();}DbgInd-=2;
#endif
	return(SUCCESS);
}
