Home      Ask a Question      My Stuff      Help   
  
Scripting - How To Write an IF Statement
It may help to know a little bit about what scripting can do, before reading this article. This article is mainly intended to explain the parts of an IF statement and the correct syntax that must be used when writing a script.

When you write an IF statement, you are basically writing, "if _______ is true, then do _______", in a way that the computer can understand.

All "IF" statements contain a pair of parentheses and a pair of "brackets". The following example will show this is written without any keywords. (You can actually use this example to start every IF statement you will ever write, then just fill in the rest.)

     if(){}


To actually use this in a script, you will fill in the parameters and commands that will accomplish the custom processing that is needed. The following example shows what each part of the IF statment does:

     if ( statment that can be evaluated as "TRUE" or "FALSE" ) { Commands that should run when the IF statement is TRUE }


Here is an example of a real script:

     if(x="1"){x="Office";payrate=12;}


However, we would normally write the previous script with additional "spacing" to make it easier to read, like this:

     if(x = "1")
     {
     x = "Office";
     payrate=12;
     }


For more information, please see the other "IF Statement" article links below.

Scripting (Main Page) > Scripting - Keywords (Main Page)
ID
610
Category
Training
  FAQ's
Date Created
8/8/2011 9:02:56 AM
Date Updated
2/15/2012 8:14:00 AM
Back to Search Results