FILEMAKER: Nested If Statements Vs Case Statements
Saturday, October 11, 2008 at 10:17AM From Dwayne Wright - Certified FileMaker 9 Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
QUESTION: What is the difference between the Case statement and the If functions. Are they the same thing?
ANSWER: They are similar in the fact that you can create what if type of branching using each. The main difference is that, the Case statement is much easier to write if you have a large amount of variables to test.
With If statements, you have one condition and two possible outcomes. You can nest if statement (in other words one of the outcomes can be an if statement with 1 conditional and two more possible outcomes). I couple years ago, someone wrote a checkbook package. The number conversion to text was supposed to be up to 250 nested if statements.
Case statements on the other hand are
(one condition, one outcome),
(next condition, next, outcome),
(next condition, next, outcome),
(next condition, next, outcome),
if no conditions match outcome.
When you want to add another condition/outcome, you simply type it in. You don't have to worry about the 2 outcome possibilities of an if statement. When you have many condition/outcome operations to write, Case statements are much easier to write than nesting multiple "conditions - outcome1-outcome" if statements.
=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.
© 2008 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.



