1 (edited by ms2014m 2023-03-12 15:38:19)

Topic: ANY ONE HELLP ME

Welcome .
I wanted to know a method

when the price b >= 0  total = (price b )-( price a)
when the price b = 0  total = price b = 0

Example

when the price b = 0  total = price b = 0
price a = 50
price b = 0
total    = 0


when the price b >= 0  total = (price b )-( price a)
price a = 50
price b = 200
total    = 150

Post's attachments

Attachment icon test.rar 365.5 kb, 83 downloads since 2023-03-12 

Re: ANY ONE HELLP ME

Hi,
You need to write a short script to perform the calculation.  Please see the attached example.
Also, your 'add' button should call the 'new record' function and not the 'show form' function (see the screenshot in the attachment).
Regards,
Derek

Post's attachments

Attachment icon mss2014m.zip 438.07 kb, 90 downloads since 2023-03-12 

Re: ANY ONE HELLP ME

derek wrote:

Hi,
You need to write a short script to perform the calculation.  Please see the attached example.
Also, your 'add' button should call the 'new record' function and not the 'show form' function (see the screenshot in the attachment).
Regards,
Derek


Thanks the example works fine
But when creating a project with the same specifications and writing the code, it does not work. Where is the problem?

Post's attachments

Attachment icon test2.rar 293.54 kb, 69 downloads since 2023-03-13 

Re: ANY ONE HELLP ME

When you write a script, there are 3 things to consider.
1.  What 'object' you want to take action on - in your example, you have two 'objects' - form2.edit3 (price A) and form2.edit4 (price B).
2.  What 'event' that has occurred to the 'object' - in your example it is when something changes - this is called the 'onchange' event.
3.  Naming and creating a procedure in the 'events' tab.
To create a procedure you can either
a.  double click in the relevant 'event' field for the 'object' and MVD will automatically assign a name to that procedure
b.  you can manually type in a name for your procedure and then double click.
Once you have done either a) or b) you are transferred to the script editor where you write your code for the procedure you have just created. 
If you omit Step 3 (naming / creating a procedure) in the 'events' tab, there is no link between the 'object', the 'event' and any code you write.
It is a common mistake that people make when they copy / paste code directly into the script editor;  this will not work without having first created a procedure in the 'events' tab.
This is what has happened in your case.
Have a look at the attached screenshot which I hope will clarify things.
Derek.

Post's attachments

Attachment icon screenshot.jpg 51.66 kb, 34 downloads since 2023-03-13 

Re: ANY ONE HELLP ME

derek wrote:

When you write a script, there are 3 things to consider.
1.  What 'object' you want to take action on - in your example, you have two 'objects' - form2.edit3 (price A) and form2.edit4 (price B).
2.  What 'event' that has occurred to the 'object' - in your example it is when something changes - this is called the 'onchange' event.
3.  Naming and creating a procedure in the 'events' tab.
To create a procedure you can either
a.  double click in the relevant 'event' field for the 'object' and MVD will automatically assign a name to that procedure
b.  you can manually type in a name for your procedure and then double click.
Once you have done either a) or b) you are transferred to the script editor where you write your code for the procedure you have just created. 
If you omit Step 3 (naming / creating a procedure) in the 'events' tab, there is no link between the 'object', the 'event' and any code you write.
It is a common mistake that people make when they copy / paste code directly into the script editor;  this will not work without having first created a procedure in the 'events' tab.
This is what has happened in your case.
Have a look at the attached screenshot which I hope will clarify things.
Derek.



Thank you very much
Everything works fine