Database Reference
In-Depth Information
statement. But nested If() functions are really hard to read and even harder to tweak, so if
you find that your business rules require a change in your calculation, you may rue the day
you decided to use four nested If() functions to decide which greeting method to display.
The Case() function has this form:
Case ( test1 ; result1 ; { test2 ; result2 ; ... ; defaultResult } )
You can add as many parameters as you want, in pairs, to represent a condition and the result
to be returned if that condition is True. Since the conditions and results are sequential and not
nested, you can easily read a Case() statement, no matter how many conditions you pile on.
You can even add an optional parameter after the last result. This parameter represents the
standard result—the one FileMaker uses if none of the conditions are true.
NOTE
Since the Case() function accepts several conditions, more than one condition can be True at the
same time. If so, FileMaker chooses the first True condition when it picks a result.
A calculation using the Case() function might look like this:
Case (
Get ( CurrentTime ) > Time ( 4 ; 0 ; 0 ) and Get ( CurrentTime ) < Time (
12 ; 0 ; 0 ) ;
"Good Morning" ;
Get ( CurrentTime ) ≥ Time ( 12 ; 0 ; 0 ) and Get ( CurrentTime ) < Time (
18 ; 0 ; 0 ) ;
"Good Afternoon" ;
Get ( CurrentTime ) ≥ Time ( 18 ; 0 ; 0 ) and Get ( CurrentTime ) < Time (
22 ; 0 ; 0 ) ;
"Good Evening" ;
"Go To Bed"
)
In this calculation, the Case() function checks first to see if the current time is between 4:00
a.m. and 12:00 p.m. If it is, then the “Good Morning” value is returned. If not, it then checks
whether the time is between 12:00 p.m. and 6:00 p.m., which would produce the “Good
Afternoon” message. Again, if not, it checks to see if it's between 6:00 p.m. and 10:00 p.m.
If so, the user sees “Good Evening.”
Search WWH ::




Custom Search