LEADTOOLS DICOM C DLL Help > Function References > L_DicomSetCharValue |
#include "Ltdic.h"
L_LTDIC_API L_BOOL L_DicomSetCharValue(hDS, pElement, pValue, nCount)
HDICOMDS hDS; |
/* a DICOM handle */ |
pDICOMELEMENT pElement; |
/* pointer to a DICOMELEMENT structure */ |
L_UCHAR * pValue; |
/* pointer to a character */ |
L_UINT32 nCount; |
/* number of values to set */ |
Sets the character value(s) of a Data Element.
Parameter |
Description |
hDS |
A DICOM handle. |
pElement |
Pointer to a DICOMELEMENT structure within the Data Set. |
pValue |
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. |
nCount |
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. |
Returns
TRUE |
The character value(s) were set successfully. |
FALSE |
Could not set the character value(s) of the Data Element. |
Comments
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.
Required DLLs and Libraries
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Win32, x64, Linux.
See Also
Example
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 String case VR_UN: // Unknown L_DicomSetCharValue(hDS, pElement, (L_UCHAR *)pValue, nCount); break; case VR_SS: // Signed Short case VR_US: // Unsigned Short case VR_OW: // Other Word String L_DicomSetShortValue(hDS, pElement, (L_INT16 *)pValue, nCount); break; case VR_SL: // Signed Long case VR_IS: // Integer String case VR_UL: // Unsigned Long case VR_AT: // Attribute Tag L_DicomSetLongValue(hDS, pElement, (L_INT32 *)pValue, nCount); break; case VR_FL: // Floating Point Single L_DicomSetFloatValue(hDS, pElement, (L_FLOAT *)pValue, nCount); break; case VR_FD: // Floating Point Double case VR_DS: // Decimal String L_DicomSetDoubleValue(hDS, pElement, (L_DOUBLE *)pValue, nCount); break; case VR_CS: // Code String case VR_SH: // Short String case VR_LO: // Long String case VR_AE: // Application Entity case VR_LT: // Long Text case VR_ST: // Short Text case VR_UI: // Unique Identifier case VR_UT: // Unlimited Text case VR_PN: // Person Name L_DicomSetStringValue(hDS, pElement, (L_TCHAR *)pValue, nCount, DICOM_CHARACTER_SET_DEFAULT); break; case VR_AS: // Age String L_DicomSetAgeValue(hDS, pElement, (pVALUEAGE)pValue, nCount); break; case VR_DA: // Date L_DicomSetDateValue(hDS, pElement, (pVALUEDATE)pValue, nCount); break; case VR_TM: // Time L_DicomSetTimeValue(hDS, pElement, (pVALUETIME)pValue, nCount); break; case VR_DT: // Date Time L_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; }