开发者

String trouble in Rave Reports 8

开发者 https://www.devze.com 2023-01-02 11:41 出处:网络
We are currently working with Delphi 2006, but we are now very ready to move on to Delphi 2010. The problem lies in our Rave reports, though...

We are currently working with Delphi 2006, but we are now very ready to move on to Delphi 2010.

The problem lies in our Rave reports, though...

We just ge开发者_StackOverflow社区t to many string errors when running our reports with Rave 8. And they just don't make any sense. (The reports compile with no error, and we can even run them without any error in Rave 6.)

Update: The errors occurs inside the event scripts in the reports itself. The errors are related to strings and string concatenation.

For instance:

//This event causes access violation (in rtl140.bpl) at run time
{ Event for Page1.OnBeforeReport }
function Page1_OnBeforeReport(Self: TRavePage);
var
  s: String;
begin
  s := 'My text in param';
  s := s + ' and som more text';
  s := copy(s,1,length(s)) + ' and then some more';           //<-- This line causes AV
  RaveProject.SetParam('MyTestParam', s);
end OnBeforeReport;


//This event works OK
{ Event for Page1.OnBeforeReport }
function Page1_OnBeforeReport(Self: TRavePage);
var
  s: String;
begin
  s := 'My text in param';
  s := s + ' and som more text';
  s := copy(s,1,length(s));                                   //<-- This line is OK
  RaveProject.SetParam('MyTestParam', s);
end OnBeforeReport;


//This event works OK too
{ Event for Page1.OnBeforeReport }
function Page1_OnBeforeReport(Self: TRavePage);
var
  s: String;
begin
  s := 'My text in param';
  s := s + ' and som more text';
  s := copy(s,1,length(s)) + s;                               //<-- This line is OK
  RaveProject.SetParam('MyTestParam', s);
end OnBeforeReport;

We really want to stick to Rave, because we have a lot of reports (150+) with a lot of functionality (sql statements, events etc). Besides, we have customers who have designed their own custom reports as well.

Does anybody know the reason for these errors?

Is there any solution or workaround to these problems?


What an accident, I do the same thing yesterday. 19 from 20 reports work fine. The problem with the one was a script using SetParam and DataMemo with ContainsRTF = True.

My solution for SetParam was to replace it with calculated fields in my DataSet. For DataMemo with ContainsRTF = True I found no solution other than switching ContainsRTF to False (but I am lucky, RTF wasn't really needed)


Since Delphi 2009 Unicode has become the default string encoding, so when you declare a String var you're getting a Unicode String instead of an Ansi String. There's no way to change the default behaviour (which has been the source of a great deal of hard-to-find-bugs and harder-if-no-impossible-to-fix ones). If the problem comes from your source code you can try explicitly changing the string encoding to ANSI instead of using the default. If the problem comes from the reports created with the Rave Editor, a workaround we found was to compile the reports with an older version of Rave (prior 7.5), which seems to work fine.


This is an incorrigible unicode problem that has been around since version 7.5.

0

精彩评论

暂无评论...
验证码 换一张
取 消