OBJECT GETPARAMETER()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

Return an API_EXPRESSION from a parameter


SYNONYM

None


SYNOPSIS

#include "dbapi.h"
 
OBJECT_GETPARAMETER(argnum, result)
 
<input parameters>
int			argnum;		/* Number of parameter to get			 */
 
<output parameters>
API_EXPRESSION	*result;		/* Pointer to a API_EXPRESSION to return result	*/


DESCRIPTION

The OBJECT_GETPARAMETER() macro is used to convert the specified parameter to an API_EXPRESSION. Parameters start a one. Objects are not converted with this macro, see OBJECT_GETOBJECT() for more information.


EXAMPLE

In the following example OBJECT_GETPARAMETER() is used to get the two parameters passed to the 'define' method as an API_EXPRESSION.

Example Recital program:

test = newobject("myclass")
// executes method 'define' and updates two properties
? test.define("Error Message", -1000)
? "test.objvalue.errorno",test.objvalue.errorno
? "test.objvalue.message",test.objvalue.message

Example in 'C' object:

#include "dbapi.h"
 
/* Define define method */
DEFINE_METHOD(clsMyClass, Define) 
{
	struct example_data *objectData = (struct example_data *)OBJECT_GETDATA();
	struct	API_EXPRESSION result;
	char	buffer[512];
	int	rc;
 
	/* Check the object class */
	OBJECT_GETPROPERTY(objectData->prop_objvalue, "class", buffer);
	rc = OBJECT_GETARG(buffer, &result);
	if (result.errno == 0 && result.type == 'C' &&
		strcmp(result.character, "Exception") == 0) { 
		switch (OBJECT_GETARGC()) {
		case 2: 
		rc = OBJECT_GETPARAMETER(2, &result);
		if (result.errno == 0 && result.type == 'N') {
			OBJECT_SETARG(buffer, &result);
			rc = OBJECT_SETPROPERTY(objectData->prop_objvalue, "errorno", buffer);
		}
 
		case 1: 
		rc = OBJECT_GETPARAMETER(1, &result);
		if (result.errno == 0 && result.type == 'C') {
			OBJECT_SETARG(buffer, &result);
			rc = OBJECT_SETPROPERTY(objectData->prop_objvalue, "message", buffer);
		}
		break;
		}
	}
 
	result.type = 'L';
	result.logical = (rc == 0 ? 'T' : 'F');
	OBJECT_RETRESULT(&result);
}


SEE ALSO

DEFINE_CLASS(), DEFINE_METHOD(), DEFINE_PROPERTYGET(), DEFINE_PROPERTYSET(), DISPATCH_FACTORY(), DISPATCH_METHOD(), DISPATCH_PROPGET(), DISPATCH_PROPSET(), OBJECT_ASSIGN(), OBJECT_DELETE(), OBJECT_GETARG(), OBJECT_GETARGC(), OBJECT_GETDATA(), OBJECT_GETOBJECT(), OBJECT_GETPROPERTY(), OBJECT_GETTYPE(), OBJECT_GETVALUE(), OBJECT_NEW(), OBJECT_RETERROR(), OBJECT_RETPROPERTY(), OBJECT_RETRESULT(), OBJECT_SETARG(), OBJECT_SETDATA(), OBJECT_SETPROPERTY()