GetShortValue Example for C++Builder
Cardinal uCount, x;
int nRet;
LEADDicom1->EnableMethodErrors = false;
/* move to the root element */
LEADDicom1->MoveFirstElement(false);
LEADDicom1->MoveRootElement();
/* insert a new element for the Short Values */
LEADDicom1->InsertElement(false, TAG_RECORD_IN_USE_FLAG, VR_US, false, 0);
Label1->Caption = "";
/* insert some short values into the element */
LEADDicom1->ShortValueCount = 5;
for(x=0; x<5; x++)
LEADDicom1->ShortValues[x] = short(x * 100);
/* set the shorts */
nRet = LEADDicom1->SetShortValue(5);
if(nRet != SUCCESS)
{
ShowMessage("Error Number: " + IntToStr(LEADDicom1->Error));
return;
}
LEADDicom1->ShortValueCount = 0; /* free the values */
/* get the value count */
uCount = LEADDicom1->GetValueCount();
ShowMessage("There are " + IntToStr(uCount) + " values!");
/* get the values */
nRet = LEADDicom1->GetShortValue(0, uCount);
if(nRet == SUCCESS)
for(x=0; x<LEADDicom1->ShortValueCount; x++)
/* display each value separated by a " X " */
Label1->Caption = Label1->Caption + " X " + IntToStr(LEADDicom1->ShortValues[x]);
ShowMessage("wait");
LEADDicom1->EnableMethodErrors = true;