<< Click to Display Table of Contents >> Navigation: Concordance Programming Fundamentals > Using Conditional Statements and Loops > About Conditional Statements |
A loop is a programming structure that allows you to run a set of code multiple times. In contrast, a conditional statement is a line of code that check for a condition, and then runs a set of code if the conditional statement is true. You use conditional statements and loops together to run code based on conditional values. For example, you could use a conditional statement to run different sections of code, depending on what the date was. Or perhaps you want to know whether the data you are processing contains a certain text phrase. You would use a conditional statement for either of those checks.
The basic conditional statement is the if-statement, which has the following syntax:
if (some conditional statement holds true) { PerformSomeTask(); PerformSomeOtherTask(); } |
Note that a conditional statement uses the same opening and closing brackets as a function. The code you place in between the brackets will only be executed if the conditional statement holds true. This is a very important point: if the statement doesn’t hold true then the section of code encapsulated between brackets is completely skipped.
The following topics discuss conditional statements and loops.
Topics |
Description |
About basic conditional operators, such as greater-than and less-than. |
|
How to put together a branching if-then-else statement. |
|
How to link multiple if-statements together. |
|
How to use a switch statement. |
|
How to loop code. |