1

I am in the transition of an old Delphi 6 application to Delphi 10 Tokyo. This code run without any problem in Delphi 6 but gives an error in Delphi XE2 or Delphi 10 Tokyo:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, COMObj;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Mosaikserver: variant;
  SystemDB: widestring;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Mosaikserver := CreateOleObject('mosaik.server');
  SystemDB :=  'C:\xxx\system.mdw';
  Mosaikserver.SystemDB := SystemDB;

end;

end.

In Delphi XE2 or Delphi 10 Tokyo, I receive a floating point divide by zero on the line: Mosaikserver.SystemDB := SystemDB; Also Mosaikserver.SystemDB := 'c:\xxx\system.mdw'; gives the same error. I guess this has something to do with Unicode strings but I don't know what exactly.

Any advice?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hub2805
  • 11
  • 1
  • Don't use global variables! Perhaps a private member of the form class? – Andreas Rejbrand Jun 03 '18 at 11:51
  • This is only an example to make it as simple as posible. In reality, the variables are properies of a class. BTW, what David Heffernan marked as a duplicate, is totaly different and gives no solution. – Hub2805 Jun 05 '18 at 05:08
  • Good. But the other question is also about floating-point exceptions. Did you try the suggestion in that answer: `SetExceptionMask(exAllArithmeticExceptions);`? – Andreas Rejbrand Jun 05 '18 at 05:53
  • Also related: [TWebBrowser - Trying to fix the “Invalid floating point operation” error](https://stackoverflow.com/questions/11869023/) – Remy Lebeau Jun 05 '18 at 20:34

0 Answers0