Welcome, Guest
Username: Password: Remember me
CodeOcean Samples and DocFactory discussions and suggestions
  • Page:
  • 1

TOPIC:

DMath example Mandel - StrToFloat raises exception 5 years 8 months ago #13313

  • Peter Heckert
  • Peter Heckert's Avatar Topic Author
  • Visitor
  • Visitor
Hi, the reason is this:

Dmath has its own "FloatStr" conversion routine that internaly uses the Pascal Str() function.
Str() does not use the global "Decimalseparator" setting, it apparently uses unconditionally "." as decimalseparator.

Here in germany we have "," as decimalseparator and because the program "Mandel" uses also the routine
FloatToStr different decimalseparators are intermixed and this causes the exception.

I believe it is the best to use "." as decimalseparator in this program unconditionally. This is common in scientific and technical software, because many other programs and measuring instruments - and DMath- use this unconditionally also.

These modifications in "mandelmw.pas" cure the problem for me:
procedure TForm1.FormActivate(Sender: TObject);
begin
  { Display center coordinates in exponential format
    using function FloatStr from unit ustrings }

  DefaultFormatSettings.DecimalSeparator:='.';      // add this line here 

  SetFormat(27, 17, True, False);
  Edit2.Text := FloatStr(x0);
  Edit3.Text := FloatStr(y0);     
procedure TForm1.Button1Click(Sender: TObject);
 var xDefaultFormatSettings : TFormatSettings;


{ Plots the Mandelbrot or Julia set }
var
  Nx, Ny : Integer;
  xt, yt : Float;
begin

  xDefaultFormatSettings:=DefaultFormatSettings;     // ct9999
  //  xDefaultFormatSettings.DecimalSeparator:=',';      //   remove this line    ct9999

  if not SetFractal(StrToFloat(Edit1.Text,xDefaultFormatSettings),
                    StrToFloat(Edit8.Text,xDefaultFormatSettings),
                    StrToFloat(Edit9.Text,xDefaultFormatSettings)) then  

Please Log in or Create an account to join the conversation.

Last edit: by Peter Heckert.

DMath example Mandel - StrToFloat raises exception 5 years 8 months ago #13314

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
Thanks Sir
we add your fix to Lab CT
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Page:
  • 1