Database Reference
In-Depth Information
POWER USERS' CLINIC: CLEVER CASE CONDITIONS
If you were one of those students who handed in homework early and always sat in the front row,
you may be jumping up and down in your chair right now, waving your hand in the air. What you're
dying to say is, “I can make that Case() function simpler!” Well, you're probably right. In fact, this
calculation does the same job:
Case (
Get ( CurrentTime ) <= Time(4;0;0) or
Get ( CurrentTime ) > Time(22;0;0);
"Go To Bed";
Get ( CurrentTime ) < Time(12;0;0);
"Good Morning";
Get ( CurrentTime ) < Time(18;0;0);
"Good Afternoon";
"Good Evening"
)
This version takes advantage of the fact that the Case() function returns the result associated with
the first True condition. FileMaker looks at the first condition, which checks to see if it's before
4:00 a.m. or after 10:00 p.m.
If either is True (note the or operator), then the function returns Go To Bed .
If both are not True, then FileMaker moves on to the second condition, which asks if it's earlier than
12:00 p.m. If so, it returns Good Morning . (What if it's 3 in the morning? That is earlier than 12:00
p.m., but you don't see “Good Morning” because FileMaker never gets this far. If it's 3:00 a.m., then
the search for truth stops after the first condition.)
If it still hasn't found a True condition, then FileMaker moves on to the next: Is it before 6:00 p.m.?
Again, the structure of the Case() statement implies that it must be after noon at this point since any
time before noon would've been caught in the previous conditions. So this condition is really look-
ing for a time between noon and 6, even though it doesn't say exactly that.
If you're comfortable with this kind of logic, then you can save yourself some clicks and a little typ-
ing. (Technically you also make a more efficient calculation, but unless you're using the abacus ver-
sion of FileMaker, you don't see a speed increase.)
Many people, on the other hand, find a calculation like this one utterly confusing. In that case, just
use the longer version, and find something else in your life to brag about.
First, you turn the GPA value into an integer (using the Round() function, so the Choose()
function can use it. When the GPA is 3.2, FileMaker rounds it to 3 and selects the result that
Search WWH ::




Custom Search