IF-Anweisung

Top  Previous  Next

if <expression> then <command>

 

Wenn der angegebene Ausdruck wahr ist, dann wird der Befehl hinter "then" ausgeführt, andernfalls setzt das Script die Ausführung in der nächsten Zeile fort.

 

Der Ausdruck <expression> hat das folgende Format:

 

Operand1 <= Operand2
Operand1 < Operand2
Operand1 <> Operand2
Operand1 = Operand2
Operand1 > Operand2
Operand1 >= Operand2

 

Operand1 und Operand2 können sein: Zahlen, Strings, Variablen und das Ergebnis einer integrierten Funktion.

 

Beispiel 1:

Springe zum Label "noUpdate" wenn keine geänderten Bookmarks existierten.

$updated = GetUpdatedBookmarkCount
if $updated=then goto noUpdate

 

Beispiel 2:

Zeige eine Frage und führe je nach geklicktem Button unterschiedliche Operationen aus.

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

 

Beispiel 3:

Eine Schleife mit 10 Durchläufen.

$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