Error in expression

Hi,

I'm learning about FastReports, to migrate my application where I'm using RaveReports. I'm using C++Builder XE5 and FastReports 4.13.2.
I want to send fixed values from C++Builder to FastReports, so I'm sending values as parameters and trying to show to in the report using a variable, but it fails and I think that there is a problem with the variable that I created inside the FastReport.

In the FastReports IDE I created a Category "Parametros" and a Variable "Saludos". Next I dragged the "Saludos" variable from the Variable tab of the Data Tree to the page.
Now, when I preview the report, it shows the following error message: "The following error(s) have occured: Saludos: Error in expression '': Expression expected".

If I delete this variable from the page and put on it a system variable, as Date for example, then the report is previewed without any problem.

What could be wrong with my own variable?

Regards,
PCerda

Comments

  • gpigpi
    edited 2:05PM
    wrote:
    I want to send fixed values from C++Builder to FastReports, so I'm sending values as parameters and trying to show to in the report using a variable, but it fails and I think that there is a problem with the variable that I created inside the FastReport.
    Show your code and tell what sript language do you use
  • edited November 2015
    Show your code and tell what sript language do you use

    In C++Builder I have a TForm with a TEdit and a TButton. In addition, I have a TfrxReport.
    This is the code for the TButton click:

    frxReport1->Variables->AddVariable("Parametros", "Saludos", Edit1->Text);
    frxReport1->ShowReport(true);

    I don't use any script language.

    The error message that I described is shown at report's designe time, so this code is not used yet, but will be helpful if you suggest how can I write correctly the code in C++.

    Regards,
    PCerda
  • Show your code and tell what sript language do you use

    In C++Builder I have a TForm with a TEdit and a TButton. In addition, I have a TfrxReport.
    This is the code for the TButton click:

    frxReport1->Variables->AddVariable("Parametros", "Saludos", Edit1->Text);
    frxReport1->ShowReport(true);

    I don't use any script language.

    The error message that I described is shown at report's designe time, so this code is not used yet, but will be helpful if you suggest how can I write correctly the code in C++.

    Regards,
    PCerda
  • gpigpi
    edited 2:05PM
    Use frxReport1->Variables->Variables["Var"] = "\"Test\""; if TfrxReport->ScriptLanguage = C++Script
  • gpi wrote: »
    Use frxReport1->Variables->Variables["Var"] = "\"Test\""; if TfrxReport->ScriptLanguage = C++Script

    Thanks for your suggestions, but it doesn't solved the problem.
    If I use your suggested code on my test application on C++Builder, and click the button with the application running, there is the following error message:

    Debugger Exception Notification
    Project Project1.exe raised exception class $C0000005 with message 'access violation at 0x009c3d34: read of address 0x00000000'.

    I insist that the problem is inside of FastReports IDE, because there is an error message before than I start my test application on C++Builder.
    I just open the FastReports IDE from the TfrxReport component, create a Category and a Variable, drag this Variable to the report page, click on Preview, and there is the error message:

    Error
    The following error(s) have occured:
    Var: Error in expression '': Expression expected
  • Use frxReport1->Variables->Variables["Var"] = "\"Test\""; if TfrxReport->ScriptLanguage = C++Script

    Thanks for your suggestions, but it doesn't solved the problem.
    If I use your suggested code on my test application on C++Builder, and click the button with the application running, there is the following error message:

    Debugger Exception Notification
    Project Project1.exe raised exception class $C0000005 with message 'access violation at 0x009c3d34: read of address 0x00000000'.

    I insist that the problem is inside of FastReports IDE, because there is an error message before than I start my test application on C++Builder.
    I just open the FastReports IDE from the TfrxReport component, create a Category and a Variable, drag this Variable to the report page, click on Preview, and there is the error message:

    Error
    The following error(s) have occured:
    Var: Error in expression '': Expression expected

    Well, I have a couple steps forward: changing PascalScript by C++Script solved the described error inside of FastReports; in addition, I founded that if I replace the text value for the Var variable by an integer value (see the following line of code) then the report works well from C++Builder.
    The question is: Why it doesn't work with text values?

    frxReport1->Variables->Variables["MiVar"] = "\"Test\""; // With this line the report fails
    frxReport1->Variables->Variables["MiVar"] = 10; // With this line the report works well
  • Debugger Exception Notification
    Project Project1.exe raised exception class $C0000005 with message 'access violation at 0x009c3d34: read of address 0x00000000'.


    I founded that if I replace the text value for the Var variable by an integer value (see the following line of code) then the report works well from C++Builder.
    The question is: Why it doesn't work with text values?

    frxReport1->Variables->Variables["MiVar"] = "\"Test\""; // With this line the report fails
    frxReport1->Variables->Variables["MiVar"] = 10; // With this line the report works well


    Someone could help me please?
    I don't know what I'm doing wrong. I can't pass any text (string) to the FastResports; only with integers it works well.
    I'm using C++Builder XE5 on Windows10.

    Regards,
    PCerda
  • gpigpi
    edited 2:05PM
    See a demo project in the attach. Works OK. Check script language in the your report
  • gpi wrote: »
    See a demo project in the attach. Works OK. Check script language in the your report

    Sorry for my silence so many days, I was focused on another problem.

    Thanks for your demo but it does not work on my environment. The behavior is what I described on Nov 2th.
    The only way to made it work is using Integer values, but not with String values. The script language was already changed to C++Script.

    If I start from scratch and replicate the same simple example, it fails again.
    This is very frustrating.

    I don't know what else could I try.

    Regards,
    Patricio Cerda
  • I'm tried the same simple example on another environment (C++ Builder XE5 on Windows Server 2008 R2) but the error is there again, but this time it is different. May be it facilitates the localization of the problem. This is the error message: "Access violation at address 002E3D34 in module 'fs19.bpl'. Read of address 00000000."

    This is the example test that fails:

    frxReport1->Variables->Variables["MiVar"] = "\"Prueba\"";
    frxReport1->ShowReport();

    Again, if I change the String value for an Integer value everything is Ok, for example:

    frxReport1->Variables->Variables["MiVar"] = 1;
    frxReport1->ShowReport();

    Why it doesn't accept String type variables?
    I also try with Variant type but it doesn't work.

    In both cases, on the previous environment (C++ Builder on Windows 10) and on this one, I'm using Fusion VMWare 7 on a Macbook Pro.

    Any help would be appreciate.

    Regards,
    Patricio Cerda
  • gordkgordk St.Catherines On. Canada.
    edited 2:05PM
    When you pass a string value to a categorized variable the value must end up with string delimiters
    or else it triggers the expression evaluator and if it cant resolve it, it then triggers the external ongetvalue event which
    means you cant preview in the ide environment.
    for an example see the programmers manual.

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.