EGL Programming – Data Parts and Assignment Statements – 4 – Arrays
ASSIGNMENT STATEMENTS AND
-
Upload
damith-shan-abeywickrema -
Category
Documents
-
view
307 -
download
0
Transcript of ASSIGNMENT STATEMENTS AND
ASSIGNMENT STATEMENTS AND
EXPRESSIONS
Dynamics NAV 2013
Shan Abeywicrema | Jinasena Infotech | www.jinasenainfotech.com
Assignment statements assign a value to a variable. This means that a variable can represent different values at different times.
Assignment Statements
Assignment means to set a variable to a value.
When a variable has a value, it keeps that value until another value is assigned to it, or until the current set of code ends and the system no longer keeps track of the variable
Assignment
A statement in programming context is a single complete programming instruction that is written as code
Statement
Certain function calls, such as the MESSAGE function, can be a statement on their own. They are known as function call statements
[return value :=] <Function Call>
Example:: MESSAGE function
Function Call Statement
The syntax of an assignment statement is almost as easy as the syntax of the function call statement. The syntax is as follows
<variable> := <expression>
Example :: Integer Number:=10;
Assignment Statement
The “colon equals” (:=) is known as the assignment operator. You use it to assign a value or an expression that evaluates to a value to a variable.
:=
Assignment Operator
A single programming statement may span several code lines; one code line may consist of multiple statements.
Therefore, the C/AL compiler must be able to detect when one statement ends and another statement begins.
[ <statement> { ; <statement> } ] Example Integer Num:=10;
The Statement Separator
Before you can assign a variable to a value, the type of the value must match the type of the variable. However, within limits, you can automatically convert certain types in an assignment operation.
Automatic Type Conversions
You can convert variables of string data types (code and text) automatically from one to the other. For example, if Description is a variable of type Text, and CodeNumber is a variable of type Code, the following statement is valid:
CodeNumber := Description Automatic conversion does have limitations. For example, if the value of the Description text
variable has more characters than the length of the CodeNumber variable, an error occurs when the program runs and executes this statement. This type of error is known as a run-time error.
String Data Types
Variables of the numeric data types (integer, decimal, option, and char) can convert automatically from one to another
Numeric Data Types
Demonstration: Create a Simple Assignment Statement
Use Assignment Statements and the Symbol Menu
Demonstration: Set Option Constants
Demonstration: Compile-Time and Run-Time Errors
Expression An expression specifies the information to
generate a desired value. Similar to a variable and a constant, an expression has a type and a value. expression is evaluated at run time to determine its value.
Quantity * UnitCost
Expressions, Terms, and Operators