Skip 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.

Simple Calculation??

Featured Replies

I have a script IF statement that if a numeric fields contents is between two specified values it performs a calculation, should be easy but cannot figure it!

I.E If value is >10 and <=20.

If (

YourField >10 and YourField =< 20;

A calc;

Another calc)

You statement should look like:

If (Value > 10 and Value <= 20, true condition, false condition)

When you have any two terms separated by a logical operator such as "and", each of the terms will be individually evaluated to a logical "true" or "false" before the logical operator is applied. You were asking FM to evaluate:

(Value >10) and (<=20)

I'm not sure how FM would evaluate "<=20" as a boolean number.

-bd

  • Author

Thanks, i thought i tried that, obviously didn't!

Does FM use short circuiting technique? (Will it evaluat the right expression in a logical and if the left returns 0?)

Paul, not exactly sure what you're asking. This will work:

If [ (test 1 = 0) and (test 2 = whatever) ]

Was that what you mean? "or," "xor," "not" are also supported.

  • 1 month later...

Sort of, that is, let's say the first part of the 'if' is false : (test 1 = 0). Will Filemaker stop evaluating the expression at that point or will it still evaluate (test 2 = whatever). I guess it doesn't matter all that much since you can not do assignments within 'if' statements in FM, but maybe for optimization purposes.

In the example I gave, it wouldn't be logical for it to stop at (test 1 = 0) because that is only part of the expression. It has to evaluate up to where you could logically put an "else" statement, if that makes sense.

I'll just throw in here, since I have no idea if I'm answering your question, that one way to "comment out" part of a FileMaker script is to use:

If[0]

.. your unused script steps here

End If

If (test 1 = 0 ) evaluates to false, then I don't understand the need to evaluate (test 2 = whatever) since what is within the 'if' statement will not be executed.

Paul,

If [ (test 1 = 0) and (test 2 = 0) ]

This has an AND in it, which means it has to evaluate what's on both sides of the AND. For example, when both test 1 and test 2 are 0, the above statement is true. However, when 1 or both of the tests are not 0, then the statement is false. It's not the same as saying:

If [ (test 1 = 0, "", If (test 2 = 0, "", "These pretzels are making me thirsty.")) ]

Correct. I guess I'm talking semantics here and it doesn't really matter. Depending on the parser that FM uses like SLR or LR(1) or recursive descent, I have no idea, it is possible that if the first condition is not met, then there is no need to even evaluate the second condition. It just an optimization translators and compilers use to speed up conditional parsing.

In C/C++:

if ((0) && (x++) && (y=x)))

{ ..... }

x would never increment and y would stay the same value, since it's a short circuited statement. 0 is always false, therefore x++ and y=x are not done.

Okay I'm done and will stop beating a dead horse smile.gif

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.