Conditional Statements

A conditional statement checks to see if a specified condition is true.  If it is
then it will execute a block of code, otherwise the code is skipped and the script picks
up at the next section.

If and if...else statements are the main conditionals used to control the flow of a script.
The simplest conditional is to simply use a number or variable as the expression:

{
	if (1)
		print "True\n";
}

1 is the boolean true, so the if statement executes its code. Any number greater
than 1 is also considered true.

{
	if (23)
		print "True\n";
}

With a variable:

{
	int $value = 12;
	if ($value)
		print "True\n";
}

The if else statement gives an alternative for the script.
If the first expression is not true, then execute the else code.

{
	int $value = 0;
	if ($value)
		print "True\n";
	else
		print "False\n";
}

Their usage is pretty simple, but they can be combined into extremely complex algorithms.
All the examples below use various operators to determine what a script should do.

Here is a silly example:

{
	int $number = rand( 0, 20 );
	int $bigNumber = 10;
	
	if ($number >= $bigNumber)
	{
		print ($number + " is a big and awesome number.\n");
	}else{
		print ($number + " is small and not cool.\n");
	}
}

By the way, if the code to be executed after the if or else is just one line, you don't need the {...} brackets.

{
	int $number = rand( 0, 20 );
	int $bigNumber = 10;
	
	if ($number >= $bigNumber)
		print ($number + " is a big and awesome number.\n");
	else
		print ($number + " is small and not cool.\n");
}

I tend to use them anyway for consistency's sake, but not always.

There is also the if else statement, for joining multiple conditions.

{
	int $number = rand( 0, 30 );
	int $bigNumber = 10;
	int $reallyBig = 20;
	
	if ($number >= $bigNumber && $number < $reallyBig)
	{
		print ($number + " is a big and awesome number.\n");
	}else if ($number >= $reallyBig){
		print ($number + " is too big and is no longer cool.\n");
	}else{
		print ($number + " is small and not cool.\n");
	}
}

The Switch:case statement

Suppose you wanted to print roman numerals instead of numbers. The best way would be
to write a program that converts properly, but if you're in a hurry and only need a few numbers
you can use conditionals to do the work.
However, long if, else if statements can get confusing,
and are also annoying to type out.
For example

{
	int $number = rand( 0, 11 );
	print ($number + " in Roman is: ");
	if ($number == 1)
	{
		print "I";
	}else if ($number == 2){
		print "II";
	}else if ($number == 3){
		print "III";
	}else if ($number == 4){
		print "IV";
	}else if ($number == 5){
		print "V";
	}else if ($number == 6){
		print "VI";
	}else if ($number == 7){
		print "VII";
	}else if ($number == 8){
		print "VIII";
	}else if ($number == 9){
		print "IX";
	}else if ($number == 10){
		print "X";
	}else{
		print "Number not supported by current implemention of Roman Numeral Conversion System(C)";
	}
	print "\n";
}

Here is the switch:case way:

{
	int $number = rand( 0, 11 );
	print ($number + " in Roman is: ");
	switch ( $number )
	{
		case 1:
			print "I";
			break;
		case 2:
			print "II";
			break;
		case 3:
			print "III";
			break;
		case 4:
			print "IV";
			break;
		case 5:
			print "V";
			break;
		case 6:
			print "VI";
			break;
		case 7:
			print "VII";
			break;
		case 8:
			print "VIII";
			break;
		case 9:
			print "IX";
			break;
		case 10:
			print "X";
			break;
		default:
			print "Number not supported by current implemention of Roman Numeral Conversion System(C)";
	}
}

Each case acts the same as an else if statements, with the
default acting like the final else.
Here's the thing.  You see all those break statements? Without those in there
the script will fall through from one case to another, executing all the code.
That might seem useless, but here's why it's like that.  Imagine instead of converting to roman numerals,
you were converting from them, and that you needed to support both capital and lower case letters.
You can leave out break statements, making the code act like it contains an || "or" operator.
Compare the switch:case method:

{
	string $number = "ii";
	print ("Roman numeral " + $number + " is regular number ");
	switch( $number )
	{
		case "i":
		case "I":
			print "1";
			break;
		case "ii":
		case "II":
			print "2";
			break;
		default:
			print ($number + " is not a number currently supported by the Regular Number to Roman Numeral Conversion System.");
	}
	print "\n";
}

to the if, else if method:

{
	string $number = "ii";
	print ("Roman numeral " + $number + " is regular number ");
	if ($number == "i" || $number == "I")
	{
		print "1";
	}else if ($number == "ii" || $number == "II"){
		print "2";
	}else{
		print ($number + " is not a number currently supported by the Regular Number to Roman Numeral Conversion System.");
	}
	print "\n";
}

You'll probably prefer one method over the other, depending on which you feel more comfortable with.
I usually use a switch:case if I'm in a situation where I need to do more than one else if.
I find them easier to read and more convenient to work with, but they both do the same thing.