Function _conEvalMacroStr() Foundation
Execution of a macro expression in a string.
XPPAPIRET _conEvalMacroStr(ContainerHandle chres,
char *pszExpr);
When the passed string container does not contain a valid macro expression, an error value is returned (XPP_ERR_...). If an error occurs during execution of the expression, the error code block is called. Note: If the error code block causes a BREAK, the return value of _conEvalMacroStr() is XPP_ERR_BREAK. If the error can be rectified by the error code block, the return value is NULL.
Using this function any valid expression can be executed. Since "{|a, b| ... }" is an expression, code blocks can be created for later evaluation by_conEvalB() or returned to Xbase++. Access to PUBLIC and PRIVATE variables is also possible.
It should be noted that the runtime execution of macros is not very efficient, since the expression must be first translated each time it is executed. If an expression is to be executed frequently, it is recommended that a code block will be generated.
/*
Executes a constant macro string
*/
#include <xppcon.h>
XPPAPIRET xr
ContainerHandle chxResult;
chxResult = _conNew( NULLCONTAINER );
if (chxResult != NULLCONTAINER)
{
xr = _conEvalMacroStr( chxResult, "1+1 == 2" );
if (xr == 0)
{
/* The result in this case should be a logic type */
if( XPP_IS_LOGIC( _conType( chxResult) ) ){
/* The value should be .T.*/
}
}
else
{
/* error handling ... */
}
_conRelease( chResult );
}
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.