GetBinaryValue Example for Delphi
Procedure TForm1.TestProc1();
var
nCount: Integer;
x: Integer;
nRet: Integer;
nLen: Integer;
strBytes: String;
strByte: Byte;
begin
LEADDicomDS1.EnableMethodErrors:= False;
//move to the root element
LEADDicomDS1.MoveFirstElement (False);
LEADDicomDS1.MoveRootElement ();
Edit1.Visible:= True;
Edit1.Text:= '';
//insert some bytes into the element
strBytes:= 'This is a Test 1234!';
nLen:= Length(strBytes);
LEADDicomDS1.BinaryValueCount:= nLen;
for x:= 0 to nLen - 1 do
begin
strByte:= Byte(strBytes[x + 1]);
LEADDicomDS1.BinaryValues[x]:= strByte;
end;
//set the bytes
nRet:= LEADDicomDS1.SetBinaryValue (nLen);
if(nRet <> 0)then
begin
ShowMessage('Error');
Exit;
end;
LEADDicomDS1.BinaryValueCount:= 0; //free the values
//get the byte count
nCount:= LEADDicomDS1.DefaultInterface.Get_CurrentElement ().Length;
ShowMessage('There are ' + IntToStr(nCount) + ' bytes!');
//get the bytes
nRet:= LEADDicomDS1.GetBinaryValue(nCount);
if(nRet = 0)then
begin
for x:= 0 to LEADDicomDS1.BinaryValueCount - 1 do
begin
//display each byte as a char separated by a space
Edit1.Text:= Edit1.Text + ' ' + Chr(LEADDicomDS1.BinaryValues[x]);
end;
end;
LEADDicomDS1.EnableMethodErrors:= True;
ShowMessage('wait');
end;