Skip to main content

IF

This command executes a statement, based on a condition.


FORMAT: IF (condition, true statement, false statement) or IF (condition,true statement)


DEFINITIONS:

  • condition: A condition is most often used in the form "= text or number" but can also use the operators < > !=

EXAMPLE 1:

$player = #"player1"
IF ( $player = "Maradona", $team = "Argentina", $team = "Other")
show $team

Obtains the name of the button with ID name "player1" and uses it in the variable $player. If the $player variable contains the text "Maradona" then the $team variable will contain "Argentina", if the condition is not respect $team will contain the text value "Other". Then we display the $team variable using the SHOW command.

EXAMPLE 2:

$goal1 = count "Maradona" where row = "GOAL"
$goal2 = count "Zidane" where row = "GOAL"
IF ( $goal1 > $goal2, show "Maradona")
IF ( $goal1 < $goal2, show "Zidane")
IF ( $goal1 = $goal2, show "")

This obtains the number of instances of the row "GOAL" containing the label "Maradona" and uses it in the variable $goal1. Does the same thing in the variable $goal2, but with the label "Zidane". It then compares the result of these two variables to know what to display. If the result of $goal1 is higher than the result of $goal2, then the text "Maradona" is displayed. For the reverse, "Zidane" is shown. Nothing is displayed if the results are equal.