Skip Navigation LinksArchmage Academy : Language Syntax : If Statement Login  

 
Skip Navigation Links.
Skip Navigation Links.

If Statement

The If statement is sure to be found in any programming language you will encounter.  The idea behind it is very simple;  it checks to see if a condition is true and if so, executes the included code.  The conditions provided can be anything from checking to see if a number is greater than five, to seeing if a boolean is set to true.  This very basic yet powerful idea can be applied to many conditions.  You are also able to specify code to execute if the conditions are not met, this is called the else statement.
Examples:
var NumApples = 5;
var ApplesNeeded = 12;

If (NumApples > ApplesNeeded)
{
       trace("Make Apple Cidar");
}

var stoveIsOn = True;
var youHaveDinner = False;

If (youHaveDinner)
{
       If (stoveIsOn)
       {
             trace("Ready to cook");
        } else {
             trace("Turn Stove On");
       {
}else {
        trace("Time to go shopping");
}
  Previous PageIntroduction, Next Page Loops.