Jump to content

This topic is 7809 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi

I am having trouble with the following. I want to have an equation in a global text field which the user can edit if they wish. I then need to insert this global text field (which has fieldnames in the formula) into a Calculation field. When I try to do this, all I see is the formula text show up in the Calculation field. Is there a special way I need to insert this? Basically here is what I'm doing. I have a global text field called gCalc. In the Calculation field (called Calc), I have Calc=gCalc. This is not working as I described above, so I am obviously doing something wrong. I'm pretty new to all this, so any help would be appreciated.

Posted

Are they the same type of field? When you created the Global field, there was an option dialog box that openned that allows you to select the field type. To check this, select the field in Define Fields, and the Select the Options Button. This will give you the Dialog box again, verify that the two fields are of the same type.

HTH

Lee

LEe

Posted

What you are trying to do is not possible in Filemaker.

The formula in a calculation field is part of the database structure and Filemaker doesn't have functions or script steps to edit it.

SetField[] set the field's content not its definition, so it fails when trying to edit a calculation field, because the content is defined by the formula.

Posted

What you are after would require a very complex calculation....

Here's a very little Example :

Field1(num)

Field2 (num)

Field3 (num)

Formula (Text)

Use "A" for Addition, "D" for Division, "M" for Multiply and "S" for substraction, so that your formula looks something like "Field1 M Field2 P Field 3".

AFAK, the definitive calc could be as long as :

Case(Rightwords(Leftwords(Formula, 4), 1) = "A",Case(Rightwords(Leftwords(Formula, 2), 1) = "A",GetField(Rightwords(Leftwords(Formula, 1), 1)) + GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "M",GetField(Rightwords(Leftwords(Formula, 1), 1)) * GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "D",GetField(Rightwords(Leftwords(Formula, 1), 1)) / GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "S",GetField(Rightwords(Leftwords(Formula, 1), 1)) - GetField(Rightwords(Leftwords(Formula, 3), 1))) + GetField(Rightwords(Leftwords(Formula, 5), 1)),

Rightwords(Leftwords(Formula, 4), 1) = "M",Case(Rightwords(Leftwords(Formula, 2), 1) = "A",GetField(Rightwords(Leftwords(Formula, 1), 1)) + GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "M",GetField(Rightwords(Leftwords(Formula, 1), 1)) * GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "D",GetField(Rightwords(Leftwords(Formula, 1), 1)) / GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "S",GetField(Rightwords(Leftwords(Formula, 1), 1)) - GetField(Rightwords(Leftwords(Formula, 3), 1))) * GetField(Rightwords(Leftwords(Formula, 5), 1)),

Rightwords(Leftwords(Formula, 4), 1) = "D",Case(Rightwords(Leftwords(Formula, 2), 1) = "A",GetField(Rightwords(Leftwords(Formula, 1), 1)) + GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "M",GetField(Rightwords(Leftwords(Formula, 1), 1)) * GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "D",GetField(Rightwords(Leftwords(Formula, 1), 1)) / GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "S",GetField(Rightwords(Leftwords(Formula, 1), 1)) - GetField(Rightwords(Leftwords(Formula, 3), 1))) / GetField(Rightwords(Leftwords(Formula, 5), 1)),

Rightwords(Leftwords(Formula, 4), 1) = "S",Case(Rightwords(Leftwords(Formula, 2), 1) = "A",GetField(Rightwords(Leftwords(Formula, 1), 1)) + GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "M",GetField(Rightwords(Leftwords(Formula, 1), 1)) * GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "D",GetField(Rightwords(Leftwords(Formula, 1), 1)) / GetField(Rightwords(Leftwords(Formula, 3), 1)),Rightwords(Leftwords(Formula, 2), 1) = "S",GetField(Rightwords(Leftwords(Formula, 1), 1)) - GetField(Rightwords(Leftwords(Formula, 3), 1))) - GetField(Rightwords(Leftwords(Formula, 5), 1)))

Changing the separators would alter the calc. If you want to go that way, good luck !0

Posted

Until FM makes an Eval() function available, Ugo probably has the best and (unfortunately) most efficient idea for such a calculation. crazy.gif

This topic is 7809 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

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