LDicomDS::SetCharValue

Summary

Sets the character value(s) of a Data Element.

Syntax

#include "Ltdic.h"

L_BOOL LDicomDS::SetCharValue(pElement, pValue, nCount)

Parameters

pDICOMELEMENT pElement

Pointer to a DICOMELEMENT structure within the Data Set.

L_UCHAR * 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.

L_UINT32 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

Value Meaning
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

Platforms

Win32, x64

See Also

Functions

Topics

Example

This example sets the value for an element.

L_VOID SetValue(LDicomDS *pDS, pDICOMELEMENT pElement, L_VOID *pValue, L_UINT32 nCount) 
{ 
   switch (pElement->nVR) 
   { 
   case VR_OB:    // Other Byte String 
   case VR_UN:    // Unknown 
      pDS->SetCharValue(pElement, (L_UCHAR *)pValue, nCount); 
      break; 
 
   case VR_SS:    // Signed Short 
   case VR_US:    // Unsigned Short 
   case VR_OW:    // Other Word String 
      pDS->SetShortValue(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 
      pDS->SetLongValue(pElement, (L_INT32 *)pValue, nCount); 
      break; 
 
   case VR_FL:    // Floating Point Single 
      pDS->SetFloatValue(pElement, (L_FLOAT *)pValue, nCount); 
      break; 
 
   case VR_FD:    // Floating Point Double 
   case VR_DS:    // Decimal String 
      pDS->SetDoubleValue(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 
      pDS->SetStringValue(pElement, (L_TCHAR *)pValue, nCount, DICOM_CHARACTER_SET_DEFAULT); 
      break; 
 
   case VR_AS:    // Age String 
      pDS->SetAgeValue(pElement, (pVALUEAGE)pValue, nCount); 
      break; 
 
   case VR_DA:    // Date 
      pDS->SetDateValue(pElement, (pVALUEDATE)pValue, nCount); 
      break; 
 
   case VR_TM:    // Time 
      pDS->SetTimeValue(pElement, (pVALUETIME)pValue, nCount); 
      break; 
 
   case VR_DT:    // Date Time 
      pDS->SetDateTimeValue(pElement, (pVALUEDATETIME)pValue, nCount); 
      break; 
   } 
} 
 
L_INT LDicomDS_SetCharValueExample() 
{ 
   LDicomDS      *pDS; 
   pDICOMELEMENT  pElement; 
 
   pDS = new LDicomDS(NULL); 
   pDS->InitDS( CLASS_CR_IMAGE_STORAGE, 0); 
 
   pElement = pDS->FindFirstElement(NULL, TAG_IMAGE_TYPE, FALSE); 
   if (pElement != NULL) 
   { 
      SetValue(pDS, pElement, TEXT("ORIGINAL\0PRIMARY"), 2); 
   } 
 
   delete pDS; 
 
   return DICOM_SUCCESS; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.