Friday, July 31, 2009

IF THEN [ELSE]

IF THEN ELSE in Navision

IF THEN [ELSE]
A conditional statement is one type of control structure in C/AL.
Using Conditional Statements

By using a conditional statement, you can specify a condition and one or more commands that should be executed, according to whether the condition is evaluated as TRUE or FALSE. There are two types of conditional statements in C/AL:

1. IF THEN [ELSE], where there are two choices

2. CASE, where there are more than two choices.
IF THEN ELSE Statements

IF THEN ELSE statements have the following syntax.
IF (Condition) THEN (Statement1)
[
ELSE
(Statement2)
]This means that if (Condition) is true, then (Statement1) is executed. If (Condition) is false, then (Statement2) is executed.The square brackets around ELSE mean that this part of the statement is optional. The ELSE statement is used when different actions are executed, depending on the evaluation of (Condition).You can build even more complex control structures by nesting IF THEN ELSE statements. The following example is a typical IF THEN ELSE statement.
IF (Condition1) THEN
IF (Condition2) THEN
Statement1;
ELSE
Statement2

For More Information Visit: Navision World

1 comment:

Related Topics