Method Community

 

Nested conditional statements

Last post 08-30-2013 3:59 PM by Method_Jason. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-29-2013 3:11 PM

    Nested conditional statements

    A user named bcr_garrett posted this question a while ago and it wasn't answered. What's the best way to structure this?

    What if you have more than one condition, and no conditional operators in Method...

    An issue I had recently

    if condition1...do something1.
    if condition1 and condition2...do something2.
    if condition1 and condition3...do something3.
    if condition1 and condition2 and condition3...do something4.

  • 08-30-2013 1:07 PM In reply to

    Re: Nested conditional statements

    Hi Mike,

    In this scenario, you probably need to use several conditional statements. This is one way to structure it:


    Start Conditional Statement 1

    Do Something 1

    Start Conditional Statement 2

    Do Something 2

    End Conditional Statement 2

    Start Conditional Statement 3

    Do Something 3

    Start Conditional Statement 2

    Do Something 4

    End Conditional Statement 2

    End Conditional Statement 3

    End Conditional Statement 1


    Keep in mind that in this structure multiple Do Something's will occur if multiple conditions are met. What's your end goal? Do you need only one Do Something to occur even if multiple conditions are met?

    Jason

    Need more help? Ask us about Method consulting services

    Jason Masina
    Community Support Specialist
    Method Integration Inc.
    Toll Free: 1.888.925.6238
    Local and overseas: 416.847.0400
    Fax: 416.640.6027
    E-mail: j.masina@methodintegration.com
  • 08-30-2013 1:54 PM In reply to

    Re: Nested conditional statements

    Let's say you have a student in karate and you're progressing through the belts, and you need to pass each level before going onto the next. The default is "No belt" and the belt options progress from "Yellow" to "Orange" to "Blue"

    For a button that does these actions while looping through a grid/table of all students, I would do the following:

    • Loop through Student grid
    • Set action result “resultbelt” = No belt
      • If pass yellow exam
      • action result “resultbelt” = Yellow
        • If pass orange exam
        • action result “resultbelt” = Orange
          • If pass blue exam
          • action result “resultbelt” = Blue
          • End if
        • End if
      • End if
    • Populate “resultbelt” into field “BeltLevelAchieved” in the Student table
    • End loop through Student grid 

    Is this a good/correct/efficient way to structure this? My issue is that there's no "else" option, so I assume I have to pre-populate it.

  • 08-30-2013 3:59 PM In reply to

    Re: Nested conditional statements

    Answer

    Hi Mike,

    This logic looks perfect to me. I don't believe there is a more efficient way to do this in the current version of Method. I can't confirm, but there might be 'else' capabilities in the next version of Method. Keep an eye out for that. 

    Jason

    Need more help? Ask us about Method consulting services

    Jason Masina
    Community Support Specialist
    Method Integration Inc.
    Toll Free: 1.888.925.6238
    Local and overseas: 416.847.0400
    Fax: 416.640.6027
    E-mail: j.masina@methodintegration.com
Page 1 of 1 (4 items)