Adding a variable from BCB6

BJLBJL Brussels, Belgium
edited 8:43PM in FastReport 3.0
BCB6 and FR304

Adding a string variable from the BCB code gives the error:
Impossible to convert 'char*' to 'int'.

How to add a variable?

frxReport1->Variables["EXERCICE"] = StringVariable; // error

with no single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "" + StringVariable + ""; // error

with one single quote between the double quotes:
frxReport1->Variables["EXERCICE"] = "'" + StringVariable + "'"; // error

with 4 single quote between the double quotes as shown in the programmer's manual:
frxReport1->Variables["EXERCICE"] = "''''" + StringVariable + "''''"; // error

BJL

Comments

  • edited 8:43PM
    Have you tried this: ?

    frxReport1->Variables["EXERCICE"] = QuotedStr(StringVariable);



  • edited 8:43PM
    Sorry, wrong code.

    This one should work:

    AnsiString StringVariable = "Hello !!!";

    int index = frxReport1->Variables->IndexOf("EXERCICE");
    if(index >= 0)
    {
    frxReport1->Variables->Items[index]->Value = QuotedStr(StringVariable);
    }
  • BJLBJL Brussels, Belgium
    edited 8:43PM
    Yes, thank you. This is the way I solved creating or updating a variable from BCB. But I can't use it...
    See other message "Variable in MemoView, ";" expected".

    BJL
  • edited November 2004
    I use delphi code:

    Report.Variables:= 'abc'; // error
    Report.Variables.Items[1].Value:= 'abc'; // error



    But, I use following code, it is ok:

    procedure TfrmMain.frxReport1GetValue(const VarName: String;
    var Value: Variant);
    begin
    if VarName='Date1' then
    Value:= FormatDateTime('yyy-mm-dd', dtp1.Date)
    else if VarName='Date2' then
    Value:= FormatDateTime('yyy-mm-dd', dtp2.Date)
    else;
    end;

Leave a Comment