Forum > Packages and Libraries
FortesReport error message
(1/1)
JD:
Hi there everyone,
I'm using fortes324forlaz 3.24.2 svn version. I was upgrading an old project of mine and as I recompiled it, I got the following error messages from FortesReport's unit RLMetaVCL.pas
--- Code: ---rlmetavcl.pas(263,16) Error: range check error while evaluating constants
rlmetavcl.pas(466,39) Error: range check error while evaluating constants
--- End code ---
The first error occurred in the function below
--- Code: ---function ToMetaTextAlignment(aSource:TAlignment):TRLMetaTextAlignment;
begin
case aSource of
taLeftJustify : result:=MetaTextAlignmentLeft;
taRightJustify: result:=MetaTextAlignmentRight;
taCenter : result:=MetaTextAlignmentCenter;
else
if aSource=succ(taCenter) then <<------ Line with error
result:=MetaTextAlignmentJustify
else
result:=MetaTextAlignmentLeft;
end;
end;
--- End code ---
The second error occurred in the function below
--- Code: ---function FromMetaTextAlignment(aSource:TRLMetaTextAlignment):TAlignment;
begin
case aSource of
MetaTextAlignmentLeft : result:=taLeftJustify;
MetaTextAlignmentRight : result:=taRightJustify;
MetaTextAlignmentCenter : result:=taCenter;
MetaTextAlignmentJustify: result:=succ(taCenter); <<------ Line with error
else
result:=taLeftJustify;
end;
end;
--- End code ---
The error appears to be from the succ(taCenter). Digging further, I found that taCenter belongs to the type TAlignment
--- Code: --- TAlignment = (taLeftJustify, taRightJustify, taCenter);
--- End code ---
which could imply that succ(taCenter) does not exist.
I haven't changed anything in my old code that uses the FortesReport component so I wonder why it is suddenly behaving this way.
Your ideas/suggestions will be most welcome.
JD
Lazarus 1.1 FPC 2.6.1 svn 39042 on win32
JD:
I noticed that this error ONLY occurs in my project. When I create a new test project or when I try to compile one of the FortesReport demos, everything is fine!
So I modified the problematic line in RLMetaVCL.pas. It seems to work BUT I'm not comfortable with it.
I changed succ(taCenter) to taCenter and it seems to be OK.
Who knows if this will blow up on me later on? Any ideas?
taazz:
succ(taCenter) should return the next value of the enumeration. If I recall corectly from my delphi days if the value passed is the highest value of an enumeration then it should loop around and return the 1st value. The help files in my computer say that it should raise an error only when compiled with range check on I have tested with range check on, off from the project options and the directive in the code it always produces an error for me. the only way to stop the error from raising is to add {$MODE DELPHI} in the unit but then it does not loop back to the 1st element it just goes to the next value what ever that is overflowing the result.
I do not know why it works and how should behave outside delphi but I can tell you that as it is is a bug waiting to happen.
JD:
--- Quote from: taazz on October 13, 2012, 08:41:57 pm ---succ(taCenter) should return the next value of the enumeration.
--- End quote ---
That's what I thought too but I wonder why it is not so.
Navigation
[0] Message Index