OBJECT NEW()
PURPOSE
Instantiate an object
SYNONYM
None
SYNOPSIS
#include "dbapi.h" OBJECT_NEW(objname, classname, parameters) <input parameters> char *objname; /* name to assign to the object */ char *classname; /* class name to instantiate object from */ char *parameters; /* comma separated list of parameters */ <output parameters> none
DESCRIPTION
The OBJECT_NEW() macro is used to instantiate an object . You must assign a name to an object when it is being instantiated and may pass optional parameters.
EXAMPLE
The following example instantiates an object from a system class EXCEPTION and assigns it to the ObjValue property from the constructor in a class called clsMyClass.
Example Recital program:
test = newobject("myclass")
Example in 'C' object:
#include "dbapi.h" /* Define constructor method */ DEFINE_METHOD(clsMyClass, Constructor) { struct example_data *objectDataArea; /* Allocate memory for objects objectData area */ objectDataArea = (struct example_data *) malloc(sizeof(struct example_data)); if (objectDataArea == NULL) return(-1); /* Assign the default property values */ strcpy(objectDataArea->prop_charvalue, "Test API object"); objectDataArea->prop_numvalue = 15.2827; objectDataArea->prop_logvalue = 'F'; strcpy(objectDataArea->prop_datevalue, DATE_DATE()); strcpy(objectDataArea->prop_timevalue, DATE_DATETIME()); strcpy(objectDataArea->prop_currvalue, "15.2827"); strcpy(objectDataArea->object_name, "APIobject"); objectDataArea->prop_objvalue = OBJECT_NEW(objectDataArea->object_name, "exception", NULL); /* Set the object objectData area */ OBJECT_SETDATA((char *)objectDataArea); return(0); }
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_GETPARAMETER(), OBJECT_GETPROPERTY(), OBJECT_GETTYPE(), OBJECT_GETVALUE(), OBJECT_RETERROR(), OBJECT_RETPROPERTY(), OBJECT_RETRESULT(), OBJECT_SETARG(), OBJECT_SETDATA(), OBJECT_SETPROPERTY()