GetCharValue Example for C++Builder
Cardinal x, uCount, nLen;
int nRet;
AnsiString sChars;
char cChar;
LEADDicom1->EnableMethodErrors = false;
/* move to the root element */
LEADDicom1->MoveFirstElement(false);
LEADDicom1->MoveRootElement();
/* insert a new element for the Char Values */
LEADDicom1->InsertElement(false, TAG_PIXEL_DATA, VR_OB, false, 0);
Label1->Caption = "";
/* insert some char values into the element */
sChars = "This is a Test 1234!";
nLen = sChars.Length();
LEADDicom1->CharValueCount = nLen;
for(x = 0; x < nLen; x++)
{
cChar = sChars[x+1]; // AnsiStrings start at index 1
LEADDicom1->CharValues[x] = cChar;
}
/* set the chars */
nRet = LEADDicom1->SetCharValue(nLen);
if(nRet != SUCCESS)
{
ShowMessage("Error Number: " + IntToStr(LEADDicom1->Error));
return;
}
LEADDicom1->CharValueCount = 0; /* free the values */
/* get the value count */
uCount = LEADDicom1->GetValueCount();
ShowMessage("There are " + IntToStr(uCount) + " values!");
/* get the values */
nRet = LEADDicom1->GetCharValue(0, uCount);
if(nRet == SUCCESS)
for(x = 0; x < LEADDicom1->CharValueCount; x++)
{
/* display each value separated by a "."*/
Label1->Caption = Label1->Caption + "." + LEADDicom1->CharValues[x];
}
LEADDicom1->EnableMethodErrors = true;
ShowMessage("wait");