I am developing an application for MAC OSX 64 bits, using Delphi 10.3 and macOS Big Sur, I run into a problem trying to catch exceptions and I cannot find the solution. When an exception occurs the execution cycle does not go into the Try / Except, it seems that RTL gives an error when performing the Raise of the Exception and triggers a new 'Access Violation' exception that goes into a loop. Below you can find the test code that produces the error:
Unit8;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm8 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Str2Float(str : String) : Extended;
var
Form8: TForm8;
implementation
{$R *.fmx}
procedure TForm8.Button1Click(Sender: TObject);
var
f : extended;
begin
f:=str2float('10,7');
ShowMessage ('Resultat : '+floattostr(f));
end;
function Str2Float(str : String) : Extended;
var
dec : Char;
begin
result := 0;
if length(str) > 0 then begin
dec := FormatSettings.DecimalSeparator;
FormatSettings.DecimalSeparator := '.';
try
result := strtofloat(str);
except
on e : Exception do begin
FormatSettings.DecimalSeparator := ',';
try
result := strtofloat(str);
except
on e : Exception do begin
result := 0;
end;
end;
end;
end;
FormatSettings.DecimalSeparator := dec;
end;
end;
end.
Thank you very much for the help
RonaldK thank you very much for your advice, I have updated to Delphi 10.4.2 and the problem has been resolved.
What I don't understand is that, every time a new version of MacOS appears we will have to recompile our application, this does not happen with Windows, I have an application compiled in 2001 that continues to work perfectly today, without the need to recompile. It forces us to buy MAC machines every so often and to pay for compiler updates.
Again, thank you very much for your advice.