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

半世苍凉 提交于 2020-01-03 05:32:26

问题


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;

回答1:


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.




回答2:


Or you can use another way.

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

The function QuotedStr returns the string S, quoted with single quotes. This means that S is enclosed in single quotes, and every single quote in S is doubled. It is equivalent to a call to AnsiQuotedStr(s, '''').



来源:https://stackoverflow.com/questions/5963036/why-is-fast-report-vcl-in-delphi-raising-a-stack-overflow-exception-when-editing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!