davepain Posted March 20, 2003 Posted March 20, 2003 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.
Pupiweb Posted March 20, 2003 Posted March 20, 2003 If ( YourField >10 and YourField =< 20; A calc; Another calc)
LiveOak Posted March 20, 2003 Posted March 20, 2003 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
davepain Posted March 20, 2003 Author Posted March 20, 2003 Thanks, i thought i tried that, obviously didn't!
paulage77 Posted March 20, 2003 Posted March 20, 2003 Does FM use short circuiting technique? (Will it evaluat the right expression in a logical and if the left returns 0?)
Fitch Posted March 20, 2003 Posted March 20, 2003 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.
paulage77 Posted May 7, 2003 Posted May 7, 2003 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.
Fitch Posted May 7, 2003 Posted May 7, 2003 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
paulage77 Posted May 7, 2003 Posted May 7, 2003 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.
Fitch Posted May 8, 2003 Posted May 8, 2003 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.")) ]
paulage77 Posted May 8, 2003 Posted May 8, 2003 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now