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

Recommended Posts

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 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)

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.

Edited by LxP

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)

Create an account

Register a new account