Function _conCallMethodPa() Foundation

Calls a method of an Xbase++ object.

Syntax
XPPAPIRET _conCallMethodPa(ContainerHandle chResult,
                           char *mName,
                           ULONG numParams,
                           ContainerHandle *chParams);
Parameters
ContainerHandle chResult
When _conCallMethodPa() is executed, chResult will contain the return value of the called method.
CHAR* mName
The character pointer mName points to a string identifying the name of the method.
ULONG numParams
The amount of parameters that will be passed to the Xbase++ method. Add one for the object itself. If the method expects two parameters, for example,numParams should be set to three, because the object itself is counted, too.
ContainerHandle* chParams
*chParams points to an array of container handles, where the first array field contains the object whose method is to be called. The other array elements have to contain the parameters that shall be passed to the method.
Return

This function returns NULL if no error occured, otherwise it returns an error code (XPP_ERR_...).

Description

The function _conCallMethodPa() is used to call a method of an Xbase++ object with a variable parameter list. The parameter list is stored in an array and passed over to the method.

Examples
#include <windows.h> 

#include "xppdef.h" 
#include "xpppar.h" 
#include "xppcon.h" 

XPPRET XPPENTRY MyCAPIFunction(XppParamList paramList) 
{  /* Declare and initialize variables */ 
ContainerHandle chAnimal1, chAnimal2; 
ContainerHandle chName, chNewName; 
ContainerHandle chParams[2]; 

/* Two objects are expected as parameters. */ 
chAnimal1 = _conParam( paramList, 1, NULL ); 
chAnimal2 = _conParam( paramList, 2, NULL ); 

/* Create new container containing new name for object */ 
/* and empty container for other object.               */ 
chNewName = _conPutC( NULLCONTAINER, "Sheep in wolf clothing" ); 
chName = _conNew( NULLCONTAINER ); 

/* Retrieve name of object one and set new name for object two. */ 
_conGetMember( chAnimal1, "NAME", chName ); 
_conSetMember( chAnimal2, "NAME", chNewName ); 

/* Prepare method call */ 
chParams[0]=chAnimal2; 
chParams[1]=chName; 

/* Call object's method. */ 
_conCallMethodPa( chAnimal2, "EAT", 2, chParams ); 

/* Return */ 
_conReturn( paramList, chName ); 

/* Release containers */ 
_conRelease( chAnimal1 ); 
_conRelease( chAnimal2 ); 
_conRelease( chName ); 
_conRelease( chNewName ); 
_conRelease( chParams ); 
} 


/* Xbase++ code */ 
CLASS Animal 
EXPORTED: 
VAR Name 
INLINE METHOD Init( cName ) 
   ::Name := cName 
RETURN self 

INLINE METHOD Eat( cFood ) 
    ? ::Name, "eats", cFood 
RETURN self 
ENDCLASS 


PROCEDURE Main 
LOCAL oWolf  := Animal():New( "Wolf" ) 
LOCAL oSheep := Animal():New( "Sheep" ) 

CLS 

? MyCAPIFunction( oWolf, oSheep ) 

? oWolf:Name 
? oSheep:Name 
RETURN 

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.