Keyword Reference


If...Then

Conditionally run a single statement.

If <expression> Then statement

Parameters

expression If the expression is true, the statement is executed.

Remarks

This version of the If statement is used to execute a single statement without the overhead of an EndIf.
The expression can contain the boolean operators of And, Or, and Not as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

Related

If...Else...EndIf, Select...Case...EndSelect, Switch...EndSwitch, Ternary

Example

#include <MsgBoxConstants.au3>

; Terminates script if no command-line arguments
If $CmdLine[0] = 0 Then Exit

; Alternative:
If $CmdLine[0] = 0 Then
    Exit
EndIf

MsgBox($MB_SYSTEMMODAL, "", "Script has command-line arguments.")