This is a public Forum  publicRSS

Forum post

    thumper
    If , And, Case Statements
    Forum post posted January 16, 2010 by thumper , last edited February 9, 2012
    778 Views, 13 Comments
    Title:
    If , And, Case Statements
    Post:
    does anyone know of a good read or a good example file to better explain how the If and  case statments work? for my database its very important i learn to use this, i used it alot in .net programing but it seems to be a tad different here in filemaker.

    Answer

    • DavidAnders

      Google "if statement site:filemaker.com"

      http://www.google.com/search?q=if+statement+site%3Afilemaker.com

       

      Google "case statement site:filemaker.com"

      http://www.google.com/search?q=case+statement+site%3Afilemaker.com

       

      Google "case statement vs if statement filemaker"

      http://www.google.com/search?q=case+statement+vs+if+statement+filemaker 

    • comment

      thumper wrote:
      does anyone know of a good read or a good example file to better explain how the If and  case statments work?

      Have you read the help on these functions?

    • thumper
      yes guys i know how to google and i did read the help, i was just wondering if some there were some reads which explain things in a different way. im still having trouble understainding in some ways.
    • DavidAnders

       

      The Google search number three Link one, post two

      ============= 

      Case vs If

      http://filemakertoday.com/com/showthread.php?5536-Case-vs-If

       

      http://www.jamesng.com/filemaker/filemaker_quick_tips/index.shtml

       

      Tip 2: Case versus IF Statements
      Case statements were introduced in version 3.0 of FileMaker. They perform exactly function as an If statement, however can greatly simplify calculations. Case statements are best used in place of a nested If statement. This is best illustrated by examining two calculations which will return a number in words (in the calculated field Display), based on a numeric entry (in the field Number) Using an If statement: If(Number = 1, "One", If(Number = 2, "Two", If(Number = 3, "Three","")))
      Using a Case statement
      Case(Number = 1,"One", Number=2, "Two", Number=3,"Three")

       

      FILEMAKER: Nested If Statements Vs Case Statements

      http://dwaynewright.blogspot.com/2008/10/filemaker-nested-if-statements-vs-case.html

       

      If ( test; resultOne; resultTwo )

      http://www.fmforums.com/forum/showtopic.php?tid/193938/

       

       ===============

      Was there something specific you were looking for?

    • deltatango

      If is for yes or no.

       

      Case is for multiple conditions.

       

      For example:

       

      If(fieldA = "abc" ; "123" ; "456")

       

      This means, if fieldA contains the text abc, then return 123, all other times, return 456.

       

      If you have multiple conditions use case:

       

      Case(

      fieldA = "abc" ; "123";

      fieldA = "def" ; "456";

      fieldA = "xyz" ; "789";

      "654" 

       

      Notice the last one is all by itself. If the three conditions above it are not met, all others will return 654. You can leave out the last one as well and it will still work. Cheers. 

    • Steve Wright

      The only reason I see for using if statements these days, is when they are used as a script step

       

      As far as I am aware, both methods (if and case) 'short circuit' so to speak when a condition is true

      So I don't believe there are any speed benefits..  but correct me if Im wrong on this...

       

    • DavidAnders

      NO

       

      QUOTE deltatango

      If is for yes or no.

      Case is for multiple conditions.

      /QUOTE

       

      Nested IF statements allowed for multiple conditions.

      Case is more elegant and less confusing.

       

      Nested IF statements with Case Arguments are rare

      but allow more complexities. 

    • deltatango
      the guy is looking for a simple answer. let's all make it 10x more complicated for him please.
    • DavidAnders

      the guy is looking for a simple answer. let's all make it 10x more complicated for him please

       

      And that simple answer is?

      The simple question presupposing the simple answer?

       

      There is an ample amount of flailing about due to incomplete or inaccurate questions, due to inexperience, language differences, and experience differences.

    • Rick Whitelaw
      SW wrote:

      "The only reason I see for using if statements these days, is when they are used as a script step"

      The If FUNCTION and the If SCRIPT STEP are different animals. I point this out not to correct you, but since I've witnessed confusion over this issue on the part of novices, to clarify this in the hope of avoiding confusion.

      RW