Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Assignment statements assign a value to a variable. The value that you assign to the variable is a C/AL expression. It can be a constant or a variable, or it can consist of multiple elements of C/AL expressions. If you use a function call as the value to assign to a variable in an assignment statement, then the value that is assigned is the return value of the function.
You use the ":=" operator for assignment statements.
Example 1
The following example assigns a constant integer value to an integer variable that you have defined.
Count := 1;
Example 2
The following example assigns a value that consists of a constant, an operator, and a variable.
Amount := 2 * Price;
Example 3
The following example assigns the return value of the OPEN Function (File) to a Boolean variable that you have defined.
OK := TestFile.OPEN('C:\temp\simple.xml');
The return value of the OPEN function is optional. If you do not handle the return value in your code, then a run-time error occurs when a function returns FALSE. The following example causes a run-time error if the file C:\temp\simple.xml cannot be opened.
TestFile.OPEN('C:\temp\simple.xml');
You can handle the return value by using an IF-THEN statement.
IF TestFile.OPEN('C:\temp\simple.xml') THEN BEGIN
// continue running
ELSE
ERROR(Text001);