Conversion Error since changed from fr3 to fr4
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:
Now (in FR4) its:
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:
ToRegistryS is my Delphi's function:
FromRegistryS also is my Delphi's function:
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
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