Sets the character value(s) of a Data Element.
#include "Ltdic.h"
L_LTDIC_API L_BOOL L_DicomSetCharValue(hDS, pElement, pValue, nCount)
A DICOM handle.
Pointer to a DICOMELEMENT structure within the Data Set.
Pointer to a character or character string that contains the character value(s) to set. If you want to set multiple values in the Value Field, put all character values in this string and set nCount to the appropriate number of values.
Value that indicates the number of values to set in the Value Field. If you want to set multiple values in the Value Field, put all the character values in pValue and set nCount to the appropriate number.
| Value | Meaning |
|---|---|
| TRUE | The character value(s) were set successfully. |
| FALSE | Could not set the character value(s) of the Data Element. |
Note: You must allocate the memory for pValue.
If you want to set more than one value in the Value Field of the Data Element, put all the character values in pValue and set nCount to the corresponding number of entries. For example, if you wish to set three character values in the Value Field of the Data Element, put all three characters in pValue and set nCount to three.
If more than one value is stored in the Value Field of the Data Element, you must set all values at the same time.
A character has a standard size of one byte. When multiple characters are in pValue, the first byte of data is the first character, the second byte of data is the second character, etc. Therefore no delimiters are needed.
This function can be called only if the Value Representation of the Data Element is VR_OB, VR_SQ, or VR_UN. For more information about Value Representations, refer to Default Value Representation Table.
Win32, x64, Linux.
This example sets the value for an element
L_VOID SetValue(HDICOMDS hDS, pDICOMELEMENT pElement, L_VOID *pValue, L_UINT32 nCount){switch (pElement->nVR){case VR_OB: // Other Byte Stringcase VR_UN: // UnknownL_DicomSetCharValue(hDS, pElement, (L_UCHAR *)pValue, nCount);break;case VR_SS: // Signed Shortcase VR_US: // Unsigned Shortcase VR_OW: // Other Word StringL_DicomSetShortValue(hDS, pElement, (L_INT16 *)pValue, nCount);break;case VR_SL: // Signed Longcase VR_IS: // Integer Stringcase VR_UL: // Unsigned Longcase VR_AT: // Attribute TagL_DicomSetLongValue(hDS, pElement, (L_INT32 *)pValue, nCount);break;case VR_FL: // Floating Point SingleL_DicomSetFloatValue(hDS, pElement, (L_FLOAT *)pValue, nCount);break;case VR_FD: // Floating Point Doublecase VR_DS: // Decimal StringL_DicomSetDoubleValue(hDS, pElement, (L_DOUBLE *)pValue, nCount);break;case VR_CS: // Code Stringcase VR_SH: // Short Stringcase VR_LO: // Long Stringcase VR_AE: // Application Entitycase VR_LT: // Long Textcase VR_ST: // Short Textcase VR_UI: // Unique Identifiercase VR_UT: // Unlimited Textcase VR_PN: // Person NameL_DicomSetStringValue(hDS, pElement, (L_TCHAR *)pValue, nCount, DICOM_CHARACTER_SET_DEFAULT);break;case VR_AS: // Age StringL_DicomSetAgeValue(hDS, pElement, (pVALUEAGE)pValue, nCount);break;case VR_DA: // DateL_DicomSetDateValue(hDS, pElement, (pVALUEDATE)pValue, nCount);break;case VR_TM: // TimeL_DicomSetTimeValue(hDS, pElement, (pVALUETIME)pValue, nCount);break;case VR_DT: // Date TimeL_DicomSetDateTimeValue(hDS, pElement, (pVALUEDATETIME)pValue, nCount);break;}}L_INT DicomSetCharValueExample(L_VOID){HDICOMDS hDS;pDICOMELEMENT pElement;hDS = L_DicomCreateDS(NULL);L_DicomInitDS(hDS, CLASS_XA_BIPLANE_IMAGE_STORAGE_RETIRED, 0);pElement = L_DicomFindFirstElement(hDS, NULL, TAG_IMAGE_TYPE, FALSE);if (pElement != NULL)SetValue(hDS, pElement, "ORIGINAL\0PRIMARY", 2);L_DicomFreeDS(hDS);return DICOM_SUCCESS;}