CHAPTER 1 - Introduction to X++
CHAPTER 2 - X++ Control Statements
CHAPTER 3 - Objects and Classes
CHAPTER 4: Accessing the Database
CHAPTER 5: Exception Handling
CHAPTER 6: Security for Developers
Lesson 3 – Conditional Statements
Conditional statements in programming define conditions under which certain functions are performed. Conditional statements use logical expressions that are evaluated and return a value of either true or false.
There are three primary topics:
- If statement : The if statement evaluates a question (a condition) and executes a statement or set of statements if the condition is true. You can provide an alternative statement or set of statements that are executed if the condition is false (the else statement). if and if…else statements are the most simple conditional statements in X++. You can also use switch statements and ternary operators.
- Switch statement: The switch statement is a multi-branch language construct. You can create more than two branches by using the switch statement. This is in contrast to the if statement. You have to nest statements to create the same effect.
- Ternary operators All these are evaluated using operators: In the X++ language of Microsoft Dynamics AX, the ternary operator is a conditional statement that resolves to one of two expressions. This means that a ternary operation statement can be assigned to a variable. In comparison, an if statement provides conditional branching of program flow but cannot be assigned to a variable.
In programming languages such as X++, you can specify conditions under which a block of code must be executed or skipped. Each test evaluates to either true or false.
Different X++ keywords offer advantages depending on the details of the situation. This section has topics that describe these keywords.In the X++ language of Microsoft Dynamics AX, the ternary operator is a conditionalstatement that resolves to one of two expressions. This means that a ternary operation statement can be assigned to a variable.