paulmetzger Posted December 11, 2002 Posted December 11, 2002 once a test in a case statement is true, will filemaker do the result and quit trying the other cases, or do I have to worry about having multiple true cases?
paulmetzger Posted December 12, 2002 Author Posted December 12, 2002 Thanks, that's what I figgured it would do, but you never know how any given language and or compiler will implement the case.
BobWeaver Posted December 13, 2002 Posted December 13, 2002 True. Watch out for those Case statements that stop just before getting to the true condition. Q: Does this bus stop on Main Street? A: Yes ma'am. Just watch me, and get off one stop before I do.
Gerd Muller Posted August 25, 2003 Posted August 25, 2003 BobWeaver said: It stops after the first true case. hmm, does it really? I tried this formula: case(NOT switch, "0", sum(relation::number)) where "switch" is a global number and "relation::number" is a unstored calculation in a relation db with 100'000 records. if "switch" has the value "1", the sum will be evaluated and I have to wait about 5 seconds until FM has done. So far so good. If "switch" has the value "0", the condition becomes true and FM should not evaluate the heavy relation. BUT IT DOES! The result is 0 (correctly), but the time to evaluate the result is AGAIN 5 seconds. Am I missing something? Gerd
-Queue- Posted August 25, 2003 Posted August 25, 2003 All the evidence I've seen points to the contrary. As you noticed, Gerd, it takes the same amount of time to process a Case(), regardless of which result it produces. It also apparently uses the same amount of memory.
Logixx Posted August 25, 2003 Posted August 25, 2003 I'm nothing of an expert, but I assume calculations are far different from scripts although the FileMaker way of thinking may let us a little bit confused about that. Scripts are made of steps among which a few are crossroads. Calculations are entities that have to be evaluated as a whole. Scripts can be exited, calculations cannot. Maybe some geek could discuss this. Yet the most important is that the result is correct.
-Queue- Posted August 25, 2003 Posted August 25, 2003 True, but scripts rely on If() and End If steps, which is far different from a Case() or If() calculation. And Case() can be used in If() steps, yet it still fully evaluates each result before continuing, and there isn't much point in doing that anyway.
BobWeaver Posted August 25, 2003 Posted August 25, 2003 I should point out that in my earlier answer, I wasn't addressing the question of whether Filemaker evaluates the entire expression or not. I only meant that if more than one condition is true, then the result that is returned is the one corresponding to the first true condition. It's quite possible that FM continues to evaluate all remaining conditions of the expression even after it finds a true one.
McCormick Posted August 25, 2003 Posted August 25, 2003 One good trick for moving along case statements is the PatternCount function. You can have Case( Text="True", "Yay!", Text="Lie", "Boo!!", (PatternCount(Text,"True")>0) AND (PatternCount(Text,"Lie")>0), "You're confusing me!!!", "") This will stop on the first case if you type "True", but keep going if you wrote "True Lies", whereas if they were all PatternCounts it would stop at the first one for either entry. And if they were all "=" it wouldn't use any of them. You can do this for non-text fields, too, especially if you convert them to text first.
-Queue- Posted August 26, 2003 Posted August 26, 2003 Ah, good point. I had to reread the question a few times before I saw what he was really asking. Thanks for clarifying.
Recommended Posts
This topic is 7830 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