GetCharValue Example for Delphi
var
uCount: Cardinal;
x: Cardinal;
nRet: Integer;
nLen: Integer;
sChars: String;
cChar: AnsiChar;
begin
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 := Length(sChars);
LEADDicom1.CharValueCount := nLen;
For x := 0 To nLen - 1 do
begin
cChar := sChars[x+1];
LEADDicom1.CharValues[x] := cChar;
end;
{ set the chars }
nRet := LEADDicom1.SetCharValue(nLen);
If nRet <> SUCCESS Then
begin
ShowMessage('Error Number: ' + IntToStr(LEADDicom1.Error));
Exit;
end;
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 Then
For x := 0 To LEADDicom1.CharValueCount - 1 do
begin
{ display each value separated by a '.'}
Label1.Caption := Label1.Caption + '.' + LEADDicom1.CharValues[x];
end;
LEADDicom1.EnableMethodErrors := true;
ShowMessage('wait');
End;