IF statement

Top  Previous  Next

if <expression> then <command>

 

If the specified expressions returns TRUE, then 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=then goto noUpdate

 

Example 2:

Display a question box and perform different actions, dependent from the button that has been 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




Translate document: