December 11, 200223 yr 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?
December 12, 200223 yr Author Thanks, that's what I figgured it would do, but you never know how any given language and or compiler will implement the case.
December 13, 200223 yr 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.
August 25, 200322 yr 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
August 25, 200322 yr 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.
August 25, 200322 yr 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.
August 25, 200322 yr 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.
August 25, 200322 yr 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.
August 25, 200322 yr 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.
August 26, 200322 yr Ah, good point. I had to reread the question a few times before I saw what he was really asking. Thanks for clarifying.
Create an account or sign in to comment