Multiple Line IF Statement

Forums ProRealTime English forum ProOrder support Multiple Line IF Statement

Viewing 4 posts - 1 through 4 (of 4 total)
  • #247480

    I have a multiple line if statement used to filter out a series of constraints. I would like to know if there is a function to exit the if statement if a condition is met without running through the whole statement.

     

    Eg

    IF Condition A then

    X = 0

    ELSIF Condition B then

    X = 1

    ELSIF Condition C then

    X = 0

    ELSE

    X=1

    ENDIF

    In the example above assume there is an overlap between Condition A and B.

    If the code runs on this overlap, then X is set to 0 as it fulfils Condition A but is then set back to 1 as it fulfils Condition B

    I would like to know if there is a way to exit the statement as soon as the condition is set to 0, without it moving through the whole IF statement ?

     

    Thanks

     

     

    #247488
    JS

    An “early” exit is not possible…
    One possible solution is to adjust your conditions, for example:

    If Condition A and Condition B then

        X = 0

    ElsIf Condition B then

        X = 1

    2 users thanked author for this post.
    #247509

    ELSIF and ELSE are only executed alternatively:

    I can’t see any condition overlapping any of the other ones.

     

     

    2 users thanked author for this post.
    #247512

    Hi!
    In ProBuilder, the structure IF ... ELSIF ... ELSE ... ENDIF is specifically designed to stop evaluating as soon as one condition is met. That means, if Condition A is true, the subsequent conditions (Condition B, C, etc.) are not evaluated at all.
    So, the behavior you’re describing, where X gets reassigned after meeting Condition A,should not happen if you’re using a proper ELSIF chain.
    Here you have an example:

    Count2 will always be 0.
    If you use to if endif then it will be different:

    1 user thanked author for this post.
Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login