LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  If Multiple "Then"

    Employee
    Posted 01-29-2016 08:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Hi
    I am trying to do something like this:

    If TestNumber > 0 then Result1 = "Greater than zero" and Result2 = "It's a positive number" and Result3 = "It's not negative"

    I have tried using all kinds of brackets to group the 3 results but none worked.

    Any way I can get it to work without breaking it into 3 separate If .... Then... statements?


  • 2.  RE: If Multiple "Then"

    Employee
    Posted 01-29-2016 08:26

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: belliveaujd

    Originally posted by: jpstory
    					

    Hi
    I am trying to do something like this:

    If TestNumber > 0 then Result1 = "Greater than zero" and Result2 = "It's a positive number" and Result3 = "It's not negative"

    I have tried using all kinds of brackets to group the 3 results but none worked.

    Any way I can get it to work without breaking it into 3 separate If .... Then... statements?
    Here's a working example making use of the brackets to encapsulate multiple lines of code in a single "if" conditional statement. Simply copy and paste the code below into the Lavastorm canvas.
    NOTE: the "If" is case sensitive and should be "if"

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=56ab85094f39288d
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    TestNumber:int
    -1
    -2
    -3
    1
    2
    3
    EOX
    editor:XY=130,100
    end:Static_Data
    
    node:Filter
    bretype:core::Filter
    editor:sortkey=56ab852a381637c4
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    Result1 = str(null)
    Result2 = str(null)
    Result3 = str(null)
    
    if TestNumber > 0 then {
    	Result1 = "Greater than zero" 
    	Result2 = "It's a positive number" 
    	Result3 = "It's not negative"
    }
    
    emit *
    emit Result1, Result2, Result3
    EOX
    editor:XY=230,100
    end:Filter


  • 3.  RE: If Multiple "Then"

    Employee
    Posted 01-29-2016 08:26

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Curly brackets - {}!
    Attachments:
    sample.brg


  • 4.  RE: If Multiple "Then"

    Employee
    Posted 01-29-2016 08:28

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Perfect, thanks!


  • 5.  RE: If Multiple "Then"

    Employee
    Posted 01-29-2016 09:35

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    On a related note (courtesy of Stony), if you'd like a variable to reflect a certain value based off of comparison with a value, the 'cmp' function can be quite useful. It doesn't apply to your question as you wanted three different output columns, but if you wanted one 'Result' column stating greater/equal/ less than, it becomes a one-liner.
    Attachments:
    sample.brg