IF statement
if <expression> then <command>
If the specified expression returns TRUE, the command after then is executed. Otherwise, the Script continues with the next line.
<expression> can have the following format:
- Operand1 <= Operand2
- Operand1 < Operand2
- Operand1 <> Operand2
- Operand1 = Operand2
- Operand1 > Operand2
- Operand1 >= Operand2
Operand1 and Operand2 can be numbers, strings, variables, or the result of a built-in function.
Example 1:
Jump to the label noUpdate when no updated bookmarks are available.
$updated = GetUpdatedBookmarkCount
if $updated=0 then goto noUpdate
Example 2:
Display a question box and perform different actions, depending on the button that was clicked.
QuestionBox "Click yes or no"
if GetQuestionBoxResult="yes" then goto yes_has_been_clicked
if GetQuestionBoxResult="no" then goto no_has_been_clicked
label yes_has_been_clicked
// insert commands here
goto continue
label no_has_been_clicked
// insert commands here
label continue
Example 3:
Loop with 10 iterations.
$i=1
Label BeginLoop1
if $i > 10 then goto EndLoop1
// commands, for example a Messagebox which displays the iteration number
MessageBox "Iteration #: {$i}"
$i = $i + 1
goto BeginLoop1
Label EndLoop1