Topic: An operation thet doesn't float very well

Hello everyone

At the request of a model railway club, I created an application with MVD which carries out a bunch of various conversions allowing the creation of a network as accurately as possible.
I am submitting to you an anomaly that is bothering me.
It is located on tab 3 of the PageControl
(called 'Calculation of a slope')
On each of the tabs all the calculations are done correctly and conform to reality.
On each tab, I placed an image ('Reset') which empties all the fields to make a new entry.
On tabs 1 and 2, the event behind the image does what is expected of it: the fields are emptied without error.
The anomaly is on the third tab.
When I want to empty the fields, an exception arises which never fails to question me with its message:
'Invalid floating point operation'.
What is the relationship between a calculation operation and a simple
resetting a TEdit (in this case TEdit10, I set the field empty), something which poses no problem on the other tabs?
The information found on the Internet leaves me perplexed as it goes in all directions.
I'll turn to you if you have an idea.
(Ultimately I say to myself: is it still the multiplication by 100 which would be at the origin? The relationship with putting the content of a TEdit clear?)
Thanks in advance.
J.B.

Post's attachments

Attachment icon Conversions.zip 516.29 kb, 29 downloads since 2024-02-14 

Re: An operation thet doesn't float very well

приложние пустое

application is empty

Re: An operation thet doesn't float very well

Hello Vladimir

What do you mean by 'empty'?
When I click on Conversion.zip I see
all the files
Is this what you are talking about?
J.B.

Re: An operation thet doesn't float very well

The archive does not contain a folder with the script.

Re: An operation thet doesn't float very well

Hello Vladimir, Hello Sparrow

All my excuses !
it should be better like this
Thanks
JB

Post's attachments

Attachment icon ECHELLES_TRAINS.zip 803.5 kb, 32 downloads since 2024-02-14 

Re: An operation thet doesn't float very well

Salut Jean, Sparrow, Vladimir,
I think the issue is when you are clearing the inputs, it is at the same time trying to perform the calculation and so is hitting the dreaded 'invalid floating point' issue.
Perhaps just modify your script like this

procedure Form1_Edit10_OnChange (Sender: TObject);
Var s9,s10 : Extended;
begin
     S9  := Form1.Edit9.Value;
     S10 := Form1.Edit10.Value;
     if (form1.edit9.value <> 0) and (form1.edit10.value <> 0) then Form1.Edit11.Value := (s9 / s10)* 100;
end;

And I think that should fix it.
Derek.

Re: An operation thet doesn't float very well

Form1.Edit9.Clear;
     Form1.Edit10.Clear;
     Form1.Edit11.Clear;

Проблема в порядке выполнения операции
У Вас на изменение значения в Form1.Edit10.Clear; происходит расчет, по этому и происходит ошибка.. Там пусто
 
Problem with the order of operation
You have to change the value in Form1.Edit10.Clear; there is a calculation going on, that's why the error occurs.. It's empty

Re: An operation thet doesn't float very well

Hello Derek, Hello Vladimir
Thanks for your answers.
Derek :
I was so obsessed with this error message and what it was hiding that I forgot that the TEdit in question had an activity (OnChange) and that it prevented the field from being reset.
Thanks again.
JB