GetCharValue Example for Delphi
Procedure TForm1.TestProc2();
var
nCount: Integer;
x: Integer;
nRet: Integer;
nLen: Integer;
strChars: String;
strChar: Byte;
begin
LEADDicomDS1.EnableMethodErrors:= False;
//move to the root element
LEADDicomDS1.MoveFirstElement (False);
LEADDicomDS1.MoveRootElement ();
//insert a new element for the Char Values
LEADDicomDS1.InsertElement (False, TAG_PIXEL_DATA, VR_OB, False, 0);
Edit1.Visible:= True;
EDit1.Text:= '';
//insert some char values into the element
strChars:= 'This is a Test 1234!';
nLen:= Length(strChars);
LEADDicomDS1.CharValueCount:= nLen;
for x:= 0 to nLen - 1 do
begin
strChar:= Byte(strChars[x + 1]);
LEADDicomDS1.CharValues[x]:= Integer(strChar);
end;
//set the chars
nRet:= LEADDicomDS1.SetCharValue(nLen);
if(nRet <> 0)then
begin
ShowMessage('Error');
Exit;
end;
LEADDicomDS1.CharValueCount:= 0; //free the values
//get the value count
nCount:= LEADDicomDS1.GetValueCount ();
ShowMessage('There are ' + IntToStr(nCount) + ' values!');
//get the values
nRet:= LEADDicomDS1.GetCharValue(0, nCount);
if(nRet = 0)then
begin
for x:= 0 to LEADDicomDS1.CharValueCount - 1 do
begin
//display each value separated by a //.//
EDit1.Text:= Edit1.Text + '.' + Chr(LEADDicomDS1.CharValues[x])
end;
end;
LEADDicomDS1.EnableMethodErrors:= True;
ShowMessage('wait');
end;