MoveRootElement Example for Delphi
var
nRet1: Integer;
nRet2: Integer;
begin
LEADDicom1.EnableMethodErrors := true;
try
{ move to first element in Data Set }
LEADDicom1.MoveFirstElement(false);
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
{ move to next element in the same level of the Data Set }
LEADDicom1.MoveNextElement(true);
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
{ move to last element in the same level of the Data Set }
LEADDicom1.MoveLastElement(true);
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
{ move to previous element in the same level of the Data Set }
LEADDicom1.MovePrevElement(true);
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
{ find the first element that has a child }
LEADDicom1.EnableMethodErrors := false;
nRet1 := LEADDicom1.MoveFirstElement(false);
While nRet1 = SUCCESS do
begin
nRet2 := LEADDicom1.MoveChildElement();
If nRet2 = SUCCESS Then
begin
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
nRet1 := SUCCESS+1; { end loop }
end;
If nRet1 <> SUCCESS+1 Then
{ check next element in this same level }
nRet1 := LEADDicom1.MoveNextElement(true);
end;
LEADDicom1.EnableMethodErrors := true;
{ move back to the element{ s parent }
If nRet1 = 1 Then
begin
LEADDicom1.MoveParentElement();
LEADDicom1.FindTag(LEADDicom1.CurrentElement.Tag);
ShowMessage('Element: ' + LEADDicom1.CurrentTag.Name);
End;
except
ShowMessage('Error Number: ' + IntToStr(LEADDicom1.Error));
end;
End;