4. Designing and Writing OpenROAD Server Applications : OpenROAD Parameter Data COM Object : DeclareAttribute Method : SetAttribute Method
 
Share this page                  
SetAttribute Method
The SetAttribute method sets the value of a named parameter. After the hierarchical structure of the PDO data has been declared using DeclareAttribute calls, that structure can be populated with values using the SetAttribute method:
HRESULT SetAttribute
    (
        [in] BSTR AttributeName,
        [in] VARIANT * AttributeValue
    );
This method uses the following parameters:
AttributeName
Takes a string containing the name of the scalar attribute for which a value is to be set. If the attribute is a nested attribute, its position in the hierarchical structure is expressed using OpenROAD 4GL “dot” syntax.
If the attribute is contained in a user class array, the row number is specified using OpenROAD 4GL subscripting syntax. As in the 4GL, if the next row beyond the current last row in the array is addressed, a new row is created automatically.
Set orPDO = Server.CreateObject("OpenROAD.ParameterData")
orPDO.DeclareAttribute "p_id", "INTEGER"
orPDO.DeclareAttribute "arr_uc_dept", "UCARRAY"
orPDO.DeclareAttribute "arr_uc_dept.name", "STRING"
...
orPDO.SetAttribute "p_I", 11
orPDO.SetAttribute "arr_uc_dept[1].name", "Finance"
AttributeValue
Takes the value to be stored in the VARIANT represented by that AttributeName.
Note:  This value is always coerced to the data type declared for that attribute. Depending on the actual type and value of the AttributeValue passed in, this coercion may fail and return an error. Three special cases are supported that bypass this coercion requirement: VT_EMPTY, VT_NULL, and the OpenROAD blank DATE (an empty string stored in a DATE attribute). Those special case values are stored in the associated VARIANT even though they are technically outside the range of legal values for the declared VARIANT data types.
After a value is set, it can be changed by a subsequent call to SetAttribute specifying a different value.
Note:  This method is valid for scalar attributes only. To set a structured attribute (that is, a user class or user class array) to empty or null, you must use the SetEmpty or SetNull methods.