Expressions
This topic describes syntax rules of forming Delphi expressions.
The following items are covered in this topic:
Valid Delphi Expressions
Operators
Function calls
Set constructors
Indexes
Typecasts
Expressions
An expression is a construction that returns a value. The following table shows examples of Delphi expressions:
X
variable
@X
address of the variable X
15
integer constant
InterestRate
variable
Calc(X, Y)
function call
X * Y
product of X and Y
Z / (1 - Z)
quotient of Z and (1 - Z)
X = 1.5
Boolean
C in Range1
Boolean
not Done
negation of a Boolean
['a', 'b', 'c']
set
Char(48)
value typecast
The simplest expressions are variables and constants (described in Data types, variables, and constants). More
complex expressions are built from simpler ones using operators, function calls, set constructors, indexes, and
typecasts.
Operators
Operators behave like predefined functions that are part of the the Delphi language. For example, the expression
(X + Y)
is built from the variables
X
and
Y
, called operands, with the
+ operator; when
X
and
Y
represent integers
or reals,
(X + Y)
returns their sum. Operators include
@,
not,
^,
*,
/,
div,
mod,
and,
shl,
shr,
as,
+,
-,
or,
xor,
=,
Dostları ilə paylaş: