#1 Re: mORMot 1 » need function AddValue and property Value in TDocVariant » 2014-09-22 19:51:51

Thanks for mpv and ab's quick replies.

ab wrote:

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 ?

#2 mORMot 1 » need function AddValue and property Value in TDocVariant » 2014-09-22 02:53:26

qch1989
Replies: 4

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;

Board footer

Powered by FluxBB