Conversion Error since changed from fr3 to fr4

edited 10:18PM in FastReport 4.0
Hi,


Before I was using FR3 and added my custom functions. When I changed to FR4 found out that there were some changes in this operation.


Before (in FR3) it was:
unit myfunctions;
interface
implementation
uses SysUtils, Classes, fs_iinterpreter;
type
[b]TFunctions = class(TObject)[/b]
private
function CallMethod(Instance: TObject; ClassType: TClass;


Now (in FR4) its:
unit myfunctions;
interface
implementation
uses SysUtils, Classes, fs_iinterpreter; // you can also add a reference //to any other type
[b]TFunctions = class(TfsRTTIModule)[/b]
private
function CallMethod(Instance: TObject; ClassType: TClass;


After this change (when I started using TfsRTTIModule instead of TObject) I get this error:
"EConvertError with message "x.xxxxxx" is not a valid floating point value" on my FastReport function:

function isRegistryRights:boolean;
var rnd,x:real=0;
    res:boolean=true;
begin
   rnd:=random;
   try
       ToRegistryS('Ata_test',FloatToStr(rnd));
       x:=StrToFloat(FromRegistryS('Ata_test'));
       if RoundF(rnd,8)<>RoundF(x,8) then res:=false;
   except
       res:=false;
   end;
   result:=res;
end;


ToRegistryS is my Delphi's function:
function ToRegistryS(AKey:string; AVal: string): string;
var
  Reg: TRegistry;
begin
  Reg:= TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\xxxx\xxxxxx\xxxxxxx\', True) then
      Reg.WriteString(AKey, AVal);
  finally
    Reg.Free;
  end;
end;


FromRegistryS also is my Delphi's function:
function FromRegistryS(AKey: string): string;
var
  Reg: TRegistry;
begin
  Reg:= TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKeyReadOnly('\xxxx\xxxxxx\xxxxxxx\') then
      Result:= Reg.ReadString(AKey);
  finally
    Reg.Free;
  end
end;


Final situation is that when I generate random number, convert it to String and store it into registry, then try to read value(string) from registry and convert it to real, it brakes.

Really strange, that its own generated random real value is not valid.

Would be thankful for any suggestion how to fix this problem.
Best regards,
kirov

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.