Jump to content

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

Recommended Posts

Posted

True. Watch out for those Case statements that stop just before getting to the true condition. smile.gif

Q: Does this bus stop on Main Street?

A: Yes ma'am. Just watch me, and get off one stop before I do.

  • 8 months later...
Posted

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. smile.gif

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. frown.gif

Am I missing something?

Gerd

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

Ah, good point. I had to reread the question a few times before I saw what he was really asking. Thanks for clarifying.

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