You are not logged in.
Pages: 1
Thanks for mpv and ab's quick replies.
Just use local var TDocVariant instead of variant.
I read the doc, it seems using TDocVariantData to access directly. so my test code should be:
procedure TForm1.btnOpenformClick(Sender: TObject);
var
re: TDocVariantData;
begin
re.Init;
// edt1.text = 'abc'
re.AddValue(edt1.text, '123');
ShowMessage(re.Value['abc']);
end;
Am I right ?
and that means I have to give up the form re.abc to get the value. I still like this straightforward form.
To get or set value from a variable as name, Is that possible to let TDocVariant support default index property, then we can use re[edt1.text] to set or get value ?
I use TDocVariant as parameter and return type of a public function of my Form. I need function AddValue and property Value in TDocVariant to get and set attributes value.
I can't use the form: doc.name, cause the "name" is from a variable.
I know I can type-cast it to TDocVariantData to use them. but I think it's better i can use it in TDocVariant directly. Do I miss some handy way to do it?
here is my test code for AddValue:
procedure TForm1.btnOpenformClick(Sender: TObject);
var
re: Variant;
begin
re := TDocVariant.New;
// edt1.text = 'abc'
TDocVariantData(re).AddValue(edt1.text, '123');
ShowMessage(re.abc);
end;
Pages: 1