Dolemite50 Posted February 14, 2009 Share Posted February 14, 2009 Hi, So far I haven't been able to find the equivelent to a ternary statement in AutoIt. Does one exist? If not, how do you go about coding something like the following without a windy If-Else-EndIf?: If $var = 1 Then $str = "One" Else $str = "Two" EndIf I've been using what feels like a ghetto approach by setting the most "logical" variable first and then conditionally changing it to something else on the next line if need be ala: $str = "Two" If $var = 1 Then $str = "One" ..which knocks the lines way down but seems like horrible practice to set vars bogusly like that. Any thoughts? Thanks. Link to comment Share on other sites More sharing options...
Authenticity Posted February 14, 2009 Share Posted February 14, 2009 If more than 2 options it's belong to a Select...Case struct or maybe Switch $Something...Case and putting the ElseIf as Case Else. It's also much better because you can use range or falling through. Link to comment Share on other sites More sharing options...
ResNullius Posted February 14, 2009 Share Posted February 14, 2009 Hi, So far I haven't been able to find the equivelent to a ternary statement in AutoIt. Does one exist? If not, how do you go about coding something like the following without a windy If-Else-EndIf?: If $var = 1 Then $str = "One" Else $str = "Two" EndIf I've been using what feels like a ghetto approach by setting the most "logical" variable first and then conditionally changing it to something else on the next line if need be ala: $str = "Two" If $var = 1 Then $str = "One" ..which knocks the lines way down but seems like horrible practice to set vars bogusly like that. Any thoughts? Thanks.Check out the _IIF() function in the Misc.au3 UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now