Adding a variable from BCB6

BJLBJL Brussels, Belgium
edited 7:00PM 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 7:00PM
    Have you tried this: ?

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



  • edited 7:00PM
    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 7:00PM
    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.