Search code examples
delphidelphi-5fastreport

Why is Fast Report VCL in Delphi raising a stack overflow exception when editing a variable?


I am using Delphi 5 and Fast Report 4 to make a report application. I have defined a variable "ReportTitle" in MyReport.f3 at design time and I assigned a value for it at runtime. Why is my code raising an EStackOverflow Exception?

Here is the code sample

  frxrprt1.LoadFromFile('c:\MyReport.fr3');
  frxrprt1.Variables['ReportTitle'] := 'Sales Summary Report';
  frxrprt1.ShowReport;

Solution

  • Use this:

    frxrprt1.Variables['ReportTitle'] := '''Sales Summary Report''';
    

    The "variable" values are actually treated as full-fledged expressions; If you want it to be a string, it needs to be a standard pascal constant, using single-tick quoting; And since you're doing that from pascal code, you need to quote the quotes by double-quoting.

    You probably get the stack overflow because fast report's scripting engine is trying to make sense of whatever you wrote and runs into a recursive problem.