4. Designing and Writing OpenROAD Server Applications : OpenROAD Parameter Data COM Object : DeclareAttribute Method
 
Share this page                  
DeclareAttribute Method
The DeclareAttribute method lets you declare a named parameter and its corresponding data type. The data type is used for constructing a VARIANT to contain the named parameter when it is passed to the 4GL procedure using the RSO CallProc method:
HRESULT DeclareAttribute
    (
        [in] BSTR AttributeName,
        [in] BSTR AttributeDataType
    );
This method uses the following parameters:
AttributeName
Specifies a string that contains the name of the corresponding parameter in the 4GL procedure to be called
AttributeDataType
Specifies a string that defines the VARIANT type used when passing the data to be mapped to that 4GL parameter
The following table describes the AttributeDataType names:
AttributeDataType Name
VARIANT Type Used
"SMALLINT"
VT_I2
"INTEGER"
VT_I4
"FLOAT"
VT_R8
"DECIMAL"
VT_DECIMAL
"DATE"
VT_DATE
"MONEY"
VT_CY
"STRING"
VT_BSTR
"USERCLASS"
(nested array of VARIANT)
"UCARRAY"
(nested array of VARIANT)
A structured attribute representing a user class is declared with type "USERCLASS." A structured attribute representing a user class array is declared with type "UCARRAY." Structured attributes can be nested to any number of levels. The nested attribute names are specified using OpenROAD 4GL "dot" syntax:
Set orPDO = Server.CreateObject("OpenROAD.ParameterData")
orPDO.DeclareAttribute "p_id", "INTEGER"
orPDO.DeclareAttribute "uc_emp", "USERCLASS"
orPDO.DeclareAttribute "uc_emp.empnam", "STRING"
orPDO.DeclareAttribute "uc_emp.hiredat", "DAT"
In this example, the PDO is being constructed to pass data to a 4GL procedure where uc_emp is the name of a user class parameter in the 4GL procedure, and that user class contains at least empname and hiredate attributes.
The name of a structured attribute must be declared before any of the attributes contained in it.
All desired attributes must be declared with the DeclareAttribute method before any values are set using SetAttribute. Once a value is set, no further declarations are allowed.