Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə48/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   44   45   46   47   48   49   50   51   ...   294
DelphiLanguageGuide

Declarations and Statements
This topic describes the syntax of Delphi declarations and statements.
Aside from the uses clause (and reserved words like implementation that demarcate parts of a unit), a program
consists entirely of declarations and statements, which are organized into blocks.
This topic covers the following items:
Declarations
Simple statements such as assignment
Structured statements such as conditional tests (e.g., 
if-then
, and case), iteration (e.g., 
for
, and 
while
).
Declarations
The names of variables, constants, types, fields, properties, procedures, functions, programs, units, libraries, and
packages are called identifiers. (Numeric constants like 26057 are not identifiers.) Identifiers must be declared before
you can use them; the only exceptions are a few predefined types, routines, and constants that the compiler
understands automatically, the variable 
Result
 when it occurs inside a function block, and the variable 
Self
 when
it occurs inside a method implementation.
A declaration defines an identifier and, where appropriate, allocates memory for it. For example,
var Size: Extended;
declares a variable called 
Size
 that holds an Extended (real) value, while
function DoThis(X, Y: string): Integer;
declares a function called 
DoThis
 that takes two strings as arguments and returns an integer. Each declaration
ends with a semicolon. When you declare several variables, constants, types, or labels at the same time, you need
only write the appropriate reserved word once:
var
   Size: Extended;
   Quantity: Integer;
   Description: string
The syntax and placement of a declaration depend on the kind of identifier you are defining. In general, declarations
can occur only at the beginning of a block or at the beginning of the interface or implementation section of a unit
(after the uses clause). Specific conventions for declaring variables, constants, types, functions, and so forth are
explained in the documentation for those topics.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   44   45   46   47   48   49   50   51   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin