Function _conEvalMacro() Foundation

Executes a macro expression in a container.

Syntax
XPPAPIRET _conEvalMacro(ContainerHandle chres,
                        ContainerHandle chcMacro);
Parameters
ContainerHandle chres
Handle of a container for the result of the macro expression.
ContainerHandle chcMacro
String container which contains a macro expression. Any expression is allowed which the Xbase++ macro operator (&) can execute.
Return

When the passed string container does not have 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 _conEvalMacro() is XPP_ERR_BREAK. If the error can be rectified by the error code block, the return value is NULL.

Description

Using this function, dynamically created expressions can be evaluated. For example, initialized multidimensional arrays and code blocks can be created, functions with constant parameters can be called and PRIVATE and PUBLIC variables can be accessed.

It should be noted that the runtime execution of macros is not very efficient, since the expression must first be translated each time the macro is executed. If an expression is to be executed frequently, it is recommended that a code block will be created.

Examples
/* 
Execute a string as a macro expression 
*/ 
#include <xppcon.h> 

XPPAPIRET        xr 
ContainerHandle  chsMacro, chxResult; 

chsMacro = _conPutC( NULLCONTAINER, "1+1" ); 
chxResult = _conNew( NULLCONTAINER ); 

if (chsMacro != NULLCONTAINER  &&  chxResult != NULLCONTAINER) 
{ 
xr = _conEvalMacro( chxResult, chsMacro ); 
if (xr == 0) 
{ 
   /* The result should be a numeric */ 
   if( XPP_IS_NUM( _conType( chxResult ) ){ 
      /* The value should be 2*/ 
   } 
} 
else 
{ 
   /* error handling ... */ 
} 
_conRelease( chsMacro ); 
_conRelease( chResult ); 
} 

Feedback

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.