DS_SetDataValue
- Updated2023-02-21
- 3 minute(s) read
HRESULT DS_SetDataValue (DSHandle DSHandle, unsigned int type, const void *value, unsigned int dimension1, unsigned int dimension2);
Purpose
Sets the data value of the DataSocket object you specify.
The DataSocket object must be configured for writing. If you call this function for a DataSocket object open for reading, this function returns DISP_E_EXCEPTION (0x80020009).
When you call this function, the DataSocket object might not immediately send the new value to the DataSocket data source to which the DataSocket object is connected. If the DataSocket object is configured for WriteAutoUpdate mode, the DataSocket object sends the new value to the DataSocket data source before this function returns. If the DataSocket object is configured for Write mode, the DataSocket object sends its data value to the DataSocket data source when you call DS_Update.
Parameters
| Input | ||||||||||||||||||||
| Name | Type | Description | ||||||||||||||||||
| DSHandle | DSHandle | Pass the handle you obtained from DS_Open, DS_GetAttrHandle, or DS_CreateAttrHandle to identify the DataSocket object. | ||||||||||||||||||
| type | unsigned int | A constant to indicate the type of data you set. The DataSocket object data value can be one of the valid types or an array of one of the valid types other than CAVT_VARIANT. The valid type constants and their corresponding C/Windows types are the following:
To specify an array type, combine the CAVT_ARRAY flag with one of the above data types (other than CAVT_VARIANT) using the bitwise OR operator (|). For example, to indicate an array of long values, pass: CAVT_LONG | CAVT_ARRAY. Press <Ctrl-T> to change this parameter's ring control to a manual input box. |
||||||||||||||||||
| value | const void * | The address of a variable that contains the data value if the constant you pass in the type parameter does not indicate an array or a string, that is, the constant is a scalar. A buffer containing the data if the constant you pass in the type parameter indicates a string or an array. An array of elements of type char* if the constant you pass in the type parameter is (CAVT_CSTRING | CAVT_ARRAY). ExampleExample of scalar of type doubledouble value = 5.5; DS_SetDataValue (dsHandle, CAVT_DOUBLE, &value, 0, 0); Example of string char *value = "String Value"; DS_SetDataValue (dsHandle, CAVT_CSTRING, value, 0, 0); Example of 1D array of doubles double value[] = {4.0, 5.0, 5.5}; DS_SetDataValue (dsHandle, CAVT_DOUBLE | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0); Example of 1D array of strings char *value[] = {"String Value 1", "String Value 2"}; DS_SetDataValue (dsHandle, CAVT_CSTRING | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0); |
||||||||||||||||||
| dimension1 | unsigned int | The number of elements in the array if the value you pass in the value parameter is a 1D array. The number of elements in the first dimension of the array if the value you pass in the value parameter is a 2D array. 0 if the value you pass in the value parameter is not an array. |
||||||||||||||||||
| dimension2 | unsigned int | The number of elements in the second dimension of the array if the value you pass in the value parameter is a 2D array. 0 if the value you pass in the value parameter is not an array or is a 1D array. |
||||||||||||||||||
Return Value
| Name | Type | Description |
| status | HRESULT | The value that indicates whether an error occurred. A negative error code indicates function failure. Error codes are defined in CVIversion\toolslib\datasock\dataskt.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. Other error codes in winerror.h are generated by ActiveX Servers and are passed on to you by the DataSocket Library. |
Additional Information
Library: DataSocket Library
Include file: datasock\dataskt.h
LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later