Jump to content
Sign in to follow this  
flysurfing

Simple Calculation How to do it ?

Recommended Posts

Dear All,

Cf. my attached file.

I am trying to do something who seems quiet simple:

I have a field called Total.

I would like that when:

1/ Input a number in the field Add to Quantity it do the addition of this number into the Total Quantity field.

2/ Input a number in the field Remove of Quantity it subtract this number into the Total Quantity field.

How could i do this ?

Thanks a lot for your help !

Cheers

pictur.png

Share this post


Link to post
Share on other sites

I responded but deleted it. I'm unsure what you are trying to accomplish. If you have a Total calculation and you have two fields (one to add and one to subtract) then the Total calc would be simply:

Add to Quantity - Remove from Quantity

But I've the feeling I'm missing something else you are looking for. Can you give examples of exact how you expect the Total field to behave if you enter something in each of the fields - give us a sequence of 3-4 entries so we can see the pattern you wish to achieve. In other words, if you have a 3 in the Add field, do you want it to add to the Total but then if you change the Add number, it adjust (so the Add and Remove always equal Total) or do you want to use the Add and Remove like a calculator with the figures adjusting each time?

LaRetta :wink2:

Edited by Guest
Modified

Share this post


Link to post
Share on other sites

Hello,

Thanks for your answer dear.

But there is still a problem:

When i input a number inside the field add to quantity or remove of quantity it well do the calculation.

Only problem, when i try to delete the number i inputed in the field add to quantity systematically the number one appears in the field.

It should be great that after you input a number inside the add or remove field, the number inputed automatically disappear.

Do you know how i could fix this ?

Thanks a lot for ur help.

Share this post


Link to post
Share on other sites

Okay, I find your response a bit difficult to follow. Please repeat it using different words and, give me example of the keystrokes (adding and deleting a number) and how the total field should accumulate your results. Then we can adjust accordingly. :smile2:

Share this post


Link to post
Share on other sites

Hello,

What Is happening:

1/ I write the number 500 in the field add to quantity.

2/ I press enter.

3/ Quantity field display value 500.

4/ I now try to delete the number 500 from the field add to quantity. Then the number 1 appears in this field and is added to the total quantity field.

So It seems impossible to remove the value entered in add to quantity or remove to quantity, which means then every addition or subtraction is false.

I hope now it is more clear :

Thanks

Share this post


Link to post
Share on other sites

Can you post a quick simple file for us to view what you mean? Zip it and it can be attached at the bottom of your post where it says in blue 'Manage Files'.

I don't understand why a 1 would pop into the Add field when you delete the 500. Don't worry, we'll figure this out together!

LaRetta

Share this post


Link to post
Share on other sites

you should compress your .fp7 files before you post them as transmission could corrupt them.

but i think this is what your after?

addRemove.fp7.zip

Edited by Guest
NEW VERSION

Share this post


Link to post
Share on other sites

i just updated the sample file - a bit cleaner no need for global variable.

Share this post


Link to post
Share on other sites

Dear LaRetta,

Thanks it works now. I did a mistake before.

West Ocean, your script looks great, but when i copy it in my database it doesnt seems to work.

Could you please tell me if there is any special setup with it ?

Thanks

Share this post


Link to post
Share on other sites

i think the problem is you are in FMP8 and that doesn't support variables?

Edited by Guest
going from memory - yes 8 does variables.

Share this post


Link to post
Share on other sites

this is how it should work?

http://screencast.com/t/f5xh70D7LmJ

Share this post


Link to post
Share on other sites

Dear Ocean West,

When i use ur script, nothing happend.

I add data in plus or less field an nothing change.

What is going wrong ?

Could you please have a look to my database i posted it before.

Thanks a lot,

Share this post


Link to post
Share on other sites

each field sets the variable $qty to it self plus or minus the Quantity then zeros it self out

the variable is then set into the Quantity field because of the let statement - any referenced field used in the calculation will trigger the field to be updated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.