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


part is sometimes called the routine's body or block



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə124/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   120   121   122   123   124   125   126   127   ...   294
DelphiLanguageGuide


part is sometimes called the routine's body or block.
Procedure Declarations
A procedure declaration has the form
procedure procedureName(parameterList); directives;
  localDeclarations;
begin
  statements
end;
110


where procedureName is any valid identifier, statements is a sequence of statements that execute when the
procedure is called, and (parameterList)directives;, and localDeclarations; are optional.
Here is an example of a procedure declaration:
procedure NumString(N: Integer; var S: string);
var
  V: Integer;
begin
  V := Abs(N);
  S := '';
  repeat
    S := Chr(V mod 10 + Ord('0')) + S;
    V := V div 10;
  until V = 0;
  if N < 0 then S := '-' + S;
end;
Given this declaration, you can call the 
NumString
 procedure like this:
NumString(17, MyString);
This procedure call assigns the value '17' to 
MyString
 (which must be a string variable).
Within a procedure's statement block, you can use variables and other identifiers declared in the localDeclarations
part of the procedure. You can also use the parameter names from the parameter list (like 
N
 and 
S
 in the previous
example); the parameter list defines a set of local variables, so don't try to redeclare the parameter names in the
localDeclarations section. Finally, you can use any identifiers within whose scope the procedure declaration falls.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   120   121   122   123   124   125   126   127   ...   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