Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Inserting equation from text field into a Calc

Featured Replies

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.

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

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.

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

  • Author

Ouch!, I didn't realize it would be such a pain. Thanks for all the help.

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

It could probably be done a bit more simply using a script to parse the equation, but it would still be complicated.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.