How to set string (or AnsiString) constant in the TVarRec?

I want to pass the formatting arguments Args into the Format function. I found some examples of that, but I can't find out how to assign string constant in the TVarRec member. The following code fails on compilation with E2089 Invalid typecast.

procedure TForm1.Button1Click(Sender: TObject);
var Arguments: array of TVarRec;
begin
  SetLength(Arguments, 2);

  Arguments[0].VInteger := 111;
  Arguments[1].VAnsiString :=  PAnsiString('Text'); // I want to set this member

  ShowMessage(Format('Decimal: %d, String: %s', Arguments));
end;

Can anyone suggest me how to set the string (or AnsiString) constant to the TVarRec member ? I'm using Delphi 2009.

Thanks a lot

5
задан 19 May 2011 в 12:49
поделиться