Sign in to follow this  
Followers 0
CrewXp

Should be an easy question, how can I run two Then statements on one line?

4 posts in this topic

Should be an easy question, how can I run two Then statements on one line?

If $a=1 Then $b=2, $c=3 etc etc

I need them on one line to organize, thx

Share this post


Link to post
Share on other sites



Should be an easy question, how can I run two Then statements on one line?

If $a=1 Then $b=2, $c=3 etc etc

I need them on one line to organize, thx

If $a = 1 Then $b=2 And $c=3

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hmm... I'm afraid that won't work as expected... I'm pretty sure that your only option is as follows:

If $A = 1 Then
    $B = 2
    $C = 3
  ; etc.
  ; etc.
EndIf

Edit: Although I can clearly see where Valuater's coming from (and it's perfectly valid English), if $A were equal to 1 then I imagine that this code:

If $A = 1 Then $B = 2 And $C = 3

would set $B to False. It would initally seem strange to hear this but AutoIt would treat everything as Booleans because of the And. 2 is non-zero which evaluates to the Boolean True, while ($C = 3) would evaluate to False. True And False would simplify to False and $C would not be touched by this command.

Edited by LxP

Share this post


Link to post
Share on other sites

Hmm... I'm afraid that won't work as expected... I'm pretty sure that your only option is as follows:

If $A = 1 Then
    $B = 2
    $C = 3
  ; etc.
  ; etc.
EndIf

Edit: Although I can clearly see where Valuater's coming from (and it's perfectly valid English), if $A were equal to 1 then I imagine that this code:

If $A = 1 Then $B = 2 And $C = 3

would set $B to False. It would initally seem strange to hear this but AutoIt would treat everything as Booleans because of the And. 2 is non-zero which evaluates to the Boolean True, while ($C = 3) would evaluate to False. True And False would simplify to False and $C would not be touched by this command.

news to me... but LxP is correct

Dim $a = 1, $b, $c

If $a = 1 Then $b=2 And $c=3


MsgBox(0,"Test", $a & @CRLF & $b & @CRLF & $c )

If $a = 1 Then 
    $b=2
    $c=3
EndIf

MsgBox(0,"Test", $a & @CRLF & $b & @CRLF & $c )

thx LxP

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0