AL includes standard arithmetic operators for performing mathematical calculations:
+
(addition)-
(subtraction)*
(multiplication)/
(division)Example:
var
total: Decimal;
quantity: Integer;
price: Decimal;
begin
quantity := 10;
price := 15.5;
total := quantity * price; // total is 155.0
end;
Logical operators allow you to perform boolean logic operations, while comparison operators compare values:
Logical: AND, OR, NOT Comparison: =, <>, <, >, <=, >= Example:
var
isActive: Boolean;
count: Integer;
begin
isActive := TRUE;
count := 5;
if isActive AND (count > 0) then
Message('The record is active and count is greater than zero.');
end;
Expressions in AL can combine operators and functions to compute values. They are used in assignments, conditions, and other contexts:
var
discountRate: Decimal;
price: Decimal;
finalPrice: Decimal;
begin
discountRate := 0.1;
price := 100;
finalPrice := price * (1 - discountRate); // finalPrice is 90
end;