Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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.

Posted

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

Posted

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

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.

Posted

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

Posted

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.

Posted

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.")) ]

Posted

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

This topic is 7873 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.