    Object Pascal:   

         3 

    ..  


          Object Pascal 

     ,    Object Pascal.    
Delphi     . 

             

         ,   Object 
Pascal,      . 

              

           . 

               

          . 

             

           
 . 

           

        ,   ,  
 ,     . 


            
 .     ,    
   ,        
.        , 
   .        
,    ,    .  
  ,      ,   
. ,   ,       
 . ,   ,   ,  
  ,       
 . 

      Object Pascal 

     Delphi      :   , 
    ,     Object Pascal  
,     Delphi. 

    procedure TForml.FormCreate(Sender: TObject);
	begin                     
        ...
      end;

        ?    !     . 
    Pascal.   
""       .   
      


53

 .     
,        
,    . 
     ,        .   
   ,    .  
Object Pascal        
 ,           . 
          .  Object 
Pascal    : 

    Target := Expression 

        Target (  , 
     ) ,  
 Expression. ,   begin  end  
TForml.FormCreate       Object Pascal: 

    Caption := ', !' 

     ,  ,    , 
  Caption,  ,   ,  
 , ! , ,  ,     
 Delphi.   ,    
,   .         
    , !.  Delphi ,  
        . 
        .      
       .  , 
  ,       
 .  Delphi       
, !    . 
         ,     
  Object Pascal. ,     
,  Delphi ,     .  
       ,  Object Pascal  
    ,      
 .   ""  .     
  .         
 .     ;  ,  
 ,   ; ,     (,  
      )  . 
    Delphi    .    
TForml.FormCreate       .   
TForml  FormCreate ,  FormCreate     
   TForml.    Delphi    
,      ,    (unit). 
    ,  TForml.FormCreate,  
,      ", !" 
    . 

    unit Unitl; 
    interface 
    uses 
      Windows, Messages, SysUtils, Classes, Graphics, Controls, 
      Forms, Dialogs; 
    type 
      TForml = class(TForm) 
      procedure FormCreate(Sender: TObject); 
      private 
        {  . } 
      public 
        {  . } 
      end; 
    var 
      Forml:   TForml; 
    implementation 
    {$R  *.DFM} 
    procedure  TForml.FormCreate(Sender:   Tobject); 
    begin 
      Caption   :=   ',   !1 
    end; 
    end. 

       ,   ,  TForml,   
  ,   .   TForml  
    Forml  TForml. ,   
   ,      "". 
     

    54	 I.   

,     .    
Delphi    , ,      
  ,     "",   
 ,    PROJECT1.DPR. 

    program Projectl; 
    uses 
      SysUtils, Forms, 
      Unitl in  'Unitl.pas' { Forml}; 
    {$R  *.RES} 
    begin 
       Application.Initialize; 
       Application.CreateForm(TForml,   Forml); 
       Application.Run; 
    end. 

        .  , , 
       ,  
    ,      Object 
Pascal,       .  ,  Delphi 
 ,      ,   
.       .  
 (   )  ,     
,    . 

    program programid; 
    uses 
      unitid, unitid2, unitidS; 
    labels 
      labell, Iabel2, Iabel3; 
    const 
      constid =  constant_expression; 
    type 
      typeid  =  type_definition; 
    var 
      varl: type_definition; 
    procedure prod; 
      _; 
    function func1 : typeid; 
       _; 
    begin 
       ; 
    end. 

    , ,       . 

      
      

        ,     ( 
 ),        .  
,         . 
       . 

     uses 
    
     

     uses        
  .    , , 
, ,   ,      
.     (   
,          
  )    .  
     ,     
   ,    begin  end  
 . 

      
    ,   Object Pascal     , 
 ,  ,     . , 
     ,  ,   
       . ,   
    (  Delphi), ,   , 
        . 

     3. Object Pascal:   55 

    , ,     C++,   
   .   C/C++     
main()  Winmain().  Delphi    .  
 Delphi         
 begin ... end.   Delphi     
 ,   ,      C++    
    main(). 

            Object Pascal. 
    ,     
        
 .        . 
           ,   
Object Pascal   . 
    	     . 
    	    ,  . 
    	         . 
    	     . 
    	        
   . 
    ,  ,      Delphi  Object Pascal. 
          
    . 

      

          ,   
  .       . 
     ,     
.         
,  Pascal     ,    
  . 
     ,  ,     
     (unit),      
   .       , 
   .        . 
          .   
        ;   
      (, ,   , 
 ). 
      Pascal    -  , 
     ,      
     .          
 . 
        var,      
,     .    
  ,   ,      . 
             
 .     . 

    type 
      typel = type_definitionl; //    
      //    "type". 
      //    
      //  ,   
      //    
      //  . 
      type2 = type_definition2; //    "type"  
      //   .  
      //    
      //    , 
      type3 = typel; //  . 

      //     var 
      //  "var".   
      varl : type_definition3;  //    
      // ,     (  
      //   ). 
      var2, var3 : type_definition4; //    "var" 


    56  I.   

      //     
      // .    
      //    
      //       
      //  . 
      var4   :   typel;      //    
      // ,    
      //   
      //    . 

     Object Pascal    
     .    
  type           
  .       . 
    	          
"" . 
    	     . 
    	       . 
    	        . 
    	       ,  
.  
    	         . 
            
   . , ,  ,  
        . 
,  SizeOf()   ,  
 . 
     SizeOf      .   
  Object Pascal        
     .       
       ,    
,     .  SizeOf    
      . 

       

        ,        
 ,    ,   
 .  Object Pascal        
: ,    ,   
  ,  ,   
  .      
  .        
      .    Object Pascal   
   -,     . 

      

           .    
     .    
         
   .    . 
     Object Pascal        , 
 .    ,    . 
 ,  ,     . 
           
,        
   .     , 
     ,   ,  
      0,     1  .. 
      .   
       .  
      Object Pascal.    
. 3.1.
         Object Pascal     
        . 
     ,  X   ,   (X)  
     X. 

          
    ,     C++,     
     "++"  "--", 
    .  Delphi  
          
Pred, Succ,Dec  Inc. 

     3. Object Pascal:  	57 


     3.1.     

    	 

    Low ()		     
    High ()	     
    Ord(X)		     .   
    .     Ord  
   ,    . 
        
    Pred(X)		   .     -1 
    Succ(X)		   .     +1 
    Dec(V)		    I.  V := Pred(V) 
    Inc(V)		    1.  V := Succ(V) 


      

             , 
..     .   Object Pascal   
   ()   ().  
     ,   
          
 ,    .   
      ,       
     .  Object Pascal  
  . 

    Integer 
    Shortlnt 
    Smalllnt 
    Longlnt 
    Byte 
    Word 
    Cardinal 

     ,          
(integer).      ,      
,      , a integer    
,      .   
         ,  
    (  ,   SizeOf 
  ).         
. 3.2. 

     3.2.	  

    		 	  

    Shortlnt	-128-127				8 ,   
    Smalllnt	-32 768-32 767			16 ,   
    Longlnt		-2 147 483 648-2 147 483 647	32 ,   
    Byte		0-255					8 ,   
    Word		0-65 535				16 ,   

              
   ,    .  
  (,   ,   )    
  Object Pascal. 
         (Integer  Cardinal) 
   .    . 3.3,    
     .  ,  
 Delphi    32- . 

    58	 I.   


     3.3.    

			 			  

	Integer	-32 768-32 767			16 ,   (Smalllnt)
	Integer	-2 147 483 648-2 147 483 647	32 ,   (Longlnt)
	Cardinal	0-65 535				16 ,   (Word)
	Cardinal	0-2 147 483 647			32 ,   (Longlnt)
    
     
       C++      int, short int (  
short)  long int (  long).  int  C/C++   
Integer  Delphi, a long  C/C++ Longlnt  Delphi.  Shortlnt  
C/C++   Delphi  Shortlnt, a Smalltlnt.  
ShortInt  Delphi  /C++   signed char.  unsigned char  C/C++ 
  Byte  Delphi.  C/C++    
unsigned long,    Delphi . 

         ,    
,          ,    " 
 ".   "" ,      
(+),  (-)   (*).     , 
    ,    . 

    	 

    Abs (X)		    X 
     Div Y		     X  Y 
    X Mod Y		    X  Y 
    Odd (X)		  True (),  X   ,  False 
			()     
    Sqr (X)		   X (.. *). 


     
              
.  Basic, ,  SQR   . 

      
      /++_     (/).  Delphi  
        .


      

       ,       
.          ,  
   .       
         
 /    .  
  Pascal    ,     
 ,        . 
       Pascal      
7- ,  ASCII (American Standard Code for Information 
Interchange       ).   
   ,   ,  ,  
8-  .      
 ,      ASCII  
   .    Delphi   8- 
,    (extended) ANSI (American National 
Standards Institute     ).   
  ,     ,    
 .      Microsoft  
 ANSI,       
 .        
       16- , 
 UNICODE,    256    , 
   ANSI. 

     3. Object Pascal:  	59 

           Object Pascal 
       .
   . 

    AnsiChar	 ,      
			  ANSI 
    WideChar	   ,     
			   UNICODE.  256  
			   ANSI 

          (32 ) . 
        char.    Pascal char 
   .  Delphi char    
  AnsiChar.       
       ,   
     ,      
.       Internet  
World Wide Web         
 .    char,     
    ,   char  
  WideChar.   ,    
  ,       
 SizeOf,     .  Ord(),    
   ,   ,    
  . 

    Chr (X)		      char    
			 .  Delphi     Char(X) 
    UpCase		     


     
        char,   C/C++  Delphi.  
         -. 
 /C++   ,      . 
 int    ,   char  . 
 Delphi      .   
       Ord. 

     
      Basic     ,    . 
 Chr  Delphi   CHR$  Basic.  Ord  
Delphi,   ANSI  ,   ASC  
Basic,     . 

      

           ,  
        -, 
    .    0  1,   . 
  ,   ,   .  Object Pascal 
  -,      (True)   
(False),     .    ,   
  . 3.4. 

	 3.4.    

			 

	Boolean	1  
	ByteBool	1 
	WordBool	2  ( Word)
	LongBool	4  ( Longlnt)

          ,    
 ,  ,  ByteBool, WordBool  LongBool  
 , Boolean  .        . 
   .  Object Pascal   Boolean, 
         
 . 

    60	 I.   

      Boolean     True ()  
False ().  ByteBool, WordBool  LongBool    
  ,    Fals    
 True    ,. 

     
       Delphi     LOGICAL  FORTRAN.  
Basic,   C++     .     
    ,    ,   
       ,    
.   Basic,    C/C++     , 
  False   0  True      
.         Delphi. 

     
     C/C++     1 (True)  0 (False).  
   Delphi.     Delphi 
  ,   .     Boolean  
Delphi   charg  /++. 

     
     Basic   TRUE (  -1)  FALSE 
(  0).  Basic TRUE  FALSE,  Delphi, , 
False  True. 


      

    Type  enum_type = ( first_value, value2, valueS, last_value); 

          , 
  ,  .  Boolean     
 Object Pascal.      ,  
 True  False,      Object Pascal ,    
  : 

	Type Boolean =   (False, True); 

       Boolean  Object Pascal  ,  
          , 
   . ,    MyColor ( 
)   myRed, myGreen  myBlue ( ,  ,  
).    : 

	Type MyColor = (myRed, myGreen, myBlue); 

          : MyColor, myRed, 
myGreen  myBlue.  MyColor   , 
,   Object Pascal     
,    .      
  MyColor.        
 ,        .  
    ,       
.        
  .      
0,   1  .. 

     
       C++   enum,    Delphi.   
       . 
 Delphi       :   
  0,      .    
enum         
.  C++       
     . 


      

        ,  
     ,   
 ,  .   - 
   : 

    Type subrange_type  =  low_value...high_value; 

          . 
    ,      
  ,    .   
       ( checking). 
          ,   
       .  
        . 

     3. Object Pascal:  	61 


      

         ,     
 .  Object Pascal onp   .  
    0,     ( 
)   ,   ,   
 (  )  .   
  . 3.5. 

     3.5.   

    				 	 		 () 
					 		 

    Real		2.9E-39	1.738		11-12			6 
    Single		1.5E-45	3.438		7-8			4 
    Double		5.0E-324	1.7308		15-16			8 
    Extended	3.4E-4932	1.14932		19-20			10 
    Comp		1.0		9.218		19-20			8 
    Currency	0.0001	9.214		19-20			8 


    Ha 	
     Real       Delphi  Borland 
Pascal.        Intel,  
   Real       
 . 

        , .. ,    
 .          
 .         
 ,   ,     - 
  .      
,     ,     
 ,     ,  
. 
    ,  .    ,  
      .  Object Pascal 
       , 
           
.      ,   
  IEEE (Institute of Electrical and Electronic Engineers -
 -  ),    
Delphi       Windows,   
         . 
,    ,  0.1,    
 IEEE   ,   . -  
        
,         
  .     ,   
"" . 
          Object Pascal   
   .  Comp (computational  ) 
       -263+1  263-1,   
   9,21018  9,21018.   
        
    ,      
  ,   .    
    Comp,       
 .        100   
  ,     100,    . 
       ,    Currency.   
       .   
Currency      ,   Comp,   , 
        10 000 (  
100!)            10 000 
   .       
   .
     Delphi   System,      
 .       . 
3.6.        SysUtils  Math. 

    62  I.   


     3.6.    

    		  

    Abs (x)		   
    ()	  
    Cos ()		  (   ,    ) 
    ()		    
    Frac(x)		                                                      
    Int ()		  .   ,   
			 (  ), ..   
			   
    Ln ()		   
    Pi 		  (3,1416...)
    Round ()	    .    . 
			 "  "  ,      
			  (,     
			 0,5).    Delphi    
			 .   Intel     
			   IEEE     
			  .     " 
			" 
    Sin(x)		 x
    Sqr()		 , .. *
    Sqrt(x)		    
    runc()	  .    Int,   
			, Trunc  

     
             
 .  Basic  SQR   ,   Sqr  
Delphi   .      Delphi  
 Sgrt. 


      

      Delphi     : 
 (ShortString),  (LongString)   (WideString).   
      (  
 Delphi  ). 
      AnsiString  WideString     
 ,       
.      ,   AnsiString   
  char,   WideString    WideChar.    
  AnsiString,       , 
  UNICODE,   WideString. 
     ShortString  ,  ,  Array[0 . .255] of char. 
      ,   
   0  255 . ,  , 
   1  255.  ShortString ,  ,  
     Delphi  Borland Pascal . 
         String.     
AnsiString  ShortString   $.    {$+}, 
 String   AnsiString.    {$-},  String  
  ShortString    ,  255 . 
           Delphi 
     .    
     . 
              
    0 (#0).     AnsiString, 
ShortString  WideString,        . 
     . 

     3. Object Pascal:   63 

       -      
  ,  array[ 0..X] of char,  X   
 ,  ,       
.    - PChar  
   .    AnsiString 
   PChar. 
     . 3.7        
 . 

     
    ,   ,        
-.        
,    . ,   Basic, 
     .   AnsiString  Delphi 
  . 

     3.7.   

    			

    Concat(sl, s2, s3)	   
				.   si+s2+s3 
    Copy(s, pos, len)	    len , 
				     s 
    Delete(s, pos, len)   len    s,    
				pos 
    Insert (sourse, tar-        source    
    get,   pos)			target,     
    Length (s)		   .   LEN  
				Basic  strlen   C/C++
    Pos(substring, s)	     
				substring   s.   SUBSTR  Basic  
				strstr)   C/C++ 
    SetLength (s,		    newlen   s 
    newlen) 
    SetString		     
    Str (x, s)		       s 
    StringOfChars		      
    UniqueString		       1 
    Val(s, v, code)	  s    
				 v 


      

            ,  
     () .  
    ,      
. 
           , 
     ,     
    .     
   ,   ,      
 .         
  . 
       ,   Delphi. 
    	 
    	 
    	 
    	 
    	 
    	   
            ,   
   .      
     4, "Object Pascal:  ". 

    64  I.   


     

      
        record ()     
   .       
 : 

    record 
      fieldnamel : fieldtypel; 
      fieldname2, fieldname3 : fieldtype2; 
      case optional_tagfield : required_ordinal_type of 
      1: variantnamel : varianttype3; 
      2, 3:   variantname2 : varianttype4; 
    end; 

           .  
          .  
       . 

      

             
.       : 

    record 
      fieldnamel : fieldtypel; 
      fieldname2, fieldname3 : fieldtype2; 
    end; 

         ,      
(  )    .     
   ,    ,  

    MyRe.Fieldnamel 

            . 

     
          record  Delphi  
struct.  C++    struct,      
struct  .   C++     ,  
   Class  Delphi. 

      

       record   -  
 ,    : 

    record 
      case optional_tagfield :  required_ordinal_type of 
      1:   variantnamel : varianttypeS; 
      2,   3:   variantname2 : varianttype4; 
    end; 


     
               
Variant,        .  
,    ,     Variant.  
        . 

          .    
 .          
 ,          
,   ,      
  . 
         .    
        .
            
  ,    .     
,     . 
        ,    . 
        
 -  . 
          ,  
 Object Pascal       
.  , _     
     Variant,    , 
  . 

     3. Object Pascal:  	65 
    3  Delphi 3.   


      
       C++      Delphi   union. 


     

       -  ,    . 

    array [ordinal_type] of type_definition; 
    array [ordinal_typel, ordinal_type2] of type_definition; 

            
.            
,    .  ,   
        (ordinal_type). 
       (, 
Boolean  AnsiChar),        . 
            
 . 
               
   . , ,    : 

    var MyArray: Array [1..10] of  Integer; 

           ,  MyArray [ 3 ], 
 ,    Integer. 

     
          ,  , 
 ,    .   Basic  FORTRAN    
 .    C++     ,  FORTRAN   . 
 Basic      ,      
  OPTION BASE.    Basic     
  ,     Delphi. 

     
       C++         () . 
 Delphi      .


     

      set ()      
 256  : 

    Set of ordinal_type 

           (  
   )      0  255. 
    (  )   
  .       
    .    .

    Type  CharSet  =  set  of AnsiChar;  	//      ANSI. 
    var MyAlphaSet : CharSet;			//      CharSet. 

     set          
.        
 ( )    : 

    MyAlphaSet := ['', '', 'I', '', 'U', 'Y']; //    . 

         ,     
.      . 

     
          .   
  -      .

    66	 I.   


      

     file       , 
     ,    file  
class.      ,   
  . 

    file of Typel //      ,    
    			//     . 
    file		//         "". 
    textfile     	//         ,    
    			//    CR   LF   ("  "    " 
    			//  ") . 


     
     -      
     .    
,       
,  -,      
      .   
  -   .  Basic   
   .  C/C++  
   FILE.    Delphi     . 

      

        ,    
      (. 3.8). 

    pointer  //       , 
    ^typel   //       . 

       ( ,     ) 
  ,         ,   
 .	
            . 

     3.8.     

    	 

    New		         
			    
     @	 -   ,  
			  ,   ,  
			,   
    GetMem		        
			      

        

    ,     ,    
    .       
        .   
         -. 

    	 

    Addr		    
    Assigneed	,      Nil 
    Ptr		    

      Nil   ,    
  .    .  Object Pascal 
      ,    
 ,        
 .       , 
   : 

    type 
      PointerType = ^NotYetDefinedType; 


     3. Object Pascal:  	67 

              
 . 
      Object Pascal  Pointer    . 
       (   
Pointer    "^").      
 . 
        Pointer     . 

     
           .     
C++         . 
  C/C++    .  
Delphi    . 


      

              
.        . 
,     Turbo Pascal,  
          
  .      ,  
     ,    
     . 
            
.     ,   ,  
    procedure  function. 
      Class  Object Pascal     
.  ,        
  y,      . 
     ,  Delphi     , 
  .       
   -.    
       
-  ,       .
     Delphi        
     . ,    
  ,        TForml.FormlCreate. 
       ,      
        of object,   
      .     
    Nil.    
,     .  
      . 
       Assigned. 
             
.       . 

     
        Delphi   ,   
 ,         
 .         
    .  C/C++    
   .        ANSI  
       .   
,   ANSI,   ,     
. Delphi   ,    ANSI. 


     Variant 

     Variant    ,   
   .      , 
    Variant     .   
 Variant   ,       
   . 

      

       Record      , 
         .  
  .     ,     
       ,  
!  Variant (       )  
""       .   
Variant      , , 
   .      
      -

    68	 I.   

  /   OLE Automation.  , 
         
   .
     , , ,       
 Variant    .    
    , , ,   
;      Delphi  
.       Variant   
Variant(X). 
     Object Pascal     Variant.  
Unassigned   ,      
       .  Null   
        .   
    .  Unassigned  
     ,  , 
    ,      , 
, ,     . Unassigned ,  
      . Null  ,   
  ,       .  
, Null ,      
 . 
          
    .      
,      ,  .    
        . 
          . 
      .   ,   
 .        Variant! 
       ,    
 Variant.  ,       
VarArrayCreate. 
           OLE  
       varByte. 
   varByte     . 
       . 
        VarArrayLock  
VarArrayUnlock. 

     
           varString.   
        varOleStr. 


        

     . 3.9       
 ,    System. 

     3.9.       

    /	 

    VarArrayCreate	        
    VarArrayDimCount	      
    VarArrayHighBound	      
    VarArrayLock		   
    VarArrayLowBound	      
    VarArrayOf		      
    VarArrayRedim		     
    VarArrayUnlock	         
    Var As Type		             
    VarCast			         
    VarClear		    
    VarCopy			      
    VarFromDateTime	  ,   / 


     3. Object Pascal:  	69 


     . 3.9 

    /	

    VarlsArray		 True,      
    VarlsEmpty           True,     Unassigned 
    VarlsNull            True,     Null 
    VarToDateTime		     / 
    VarType  		        
				 


     . 3.10   ,    
 ,    . 

     3.10.   

     				  

    					varlnteger 
    ,  Currency  varDouble 
    Currency  				varCurrency 
                varString 
                               varBoolean 

            
   Object Pascal (Integer, Real, String  Boolean). 
   Delphi  .   
 ,       , 
,   ,      TypeName(V), 
 TypeName    , V   Variant. 
         
,      .    
    VarAsType  VarCast. 

    OLE Automation 

            OLE 
Automation     .    , 
   OleAuto. 
            OLE Automation 
 ,     . , ,   
. -,    OLE Automation    
 , ..   ,     
     .     
       .   , 
         . 
          OLE Automation,   
       ,    
,   . 

       

        ,  , 
   (,    )   
 .      Object Pascal,  
  ,  . ,   
       .  
         
 . 
       Object Pascal    . 3.11. 

    70  I.   


     3.11.  Object Pascal (  ) 

    				 

    .^    					  ,     ( ) 
    @ not					    
    * / div mod as and shl shr	 ,    __   
    + - or xor     			  () 
    = <><><=>= in is			  (,    
						 ) ( )

            . 
,  "+"      ,  
     ,   ""   
    . 
            
.       Object Pascal  
   . 
    ,        
  (    ,  
   ). 

    + (), - (), * (), 
    / (   ), 
    div ( ), mod (  ) 

            ( 
 ): 

    + ( ) 

      ,       
     (  ). 

    = (),  ( ), < (), > (), 
    <= (  ), >= (  ) 


     
            .  , 
,      ,    
  . -       
        .   
     ,     
 ,         . 

       ,     ,  . 
     :   .  
     ( )   
 . 

             

    not			 : 1   0, 0   1 
    and			 . I and J  ,   
				  ,  1   I  J 
    or			 . I or J  ,     
				,  0   I  J 
    xor			  . I and J  ,   
				 ,    I  J  
    shl			  . I shl J   I,   
				J  .    2 J  
    shr			  . I shl J   I,   
				J  .    2 J  

     not, and, or  xor    . 


     3. Object Pascal:  	71 


      
    ,  Object Pascal,     
 ,       
.    C++  (*)     
,    ("/")    ( Delphi  "div").  
Basic "^"      . 


     

             ,  
         
.  Object Pascal    ,   
       . 
      . 
    ,       ,    
    : 

     ; 
     . 

        ,   ,     
  . 

      

          ,  
         . 
     Object Pascal     : 

      (: =); 
     ; 
      (GoTo). 

        ,    .   
  ,       (  
  Object Pascal) .  ,   ,  
    . 
      GoTo  ,  - , .  
   .       
,          
   Pascal.  GoTo    
  .  ,       
  ,      .     
     . 
          .  
      ,    
 - .     
,    ,     
 .        
,       ,   
        . 

      

           
.      ,  
    (:=),    .   
     ,    : 

    target := expression; 

     (expression)        
 target, ,       ,  
target  expression   .    
   .      
,        , 
    .    
  ,       
.     .    
 ,   .  ,    
  ( ),      
.   -    AnsiString 
( ),   .  PChar    
 ;    .    
PChar         0, ,  
,  .    Variant    , 
,    . 

    72  I.   

     
       C++    ,    ,  
         . Delphi peae 
    ,     C/C++ (,   
 if. . .then. . .),       . 


      

      ()     , 
         : 

    procname(parml, parm2) 

          ,  
        
.        . 
         
    "  ". 
             ,   
    - . 

      

      GoTo    , 
  .   Pascal      0  
9999 (  ).  Object Pascal     
: 

    GoTo labell; 

            ,   
  GoTo.        
 .       . 
          
 .       
    .       
(break)   _ (exit)  GoTo     Object 
Pascal.

      
       ,     Basic  C/C++, 
  ,     .  Object 
Pascal, ,    ,   . 


      

           ,  
    ,   , 
  ,   ,       
 ,   ,      
  .       
     ,     
  . 
      Object Pascal      
 . 
      
      
     
     With 


      (begin...end) 

       ,     
   .     
  begin...end,     ,    
    Object Pascal: 

    Begin 
      statement1; 
      statement2; 
    end 


     3. Object Pascal:  	73 

      begin  end , ,   
 .     .  end 
    (  end    
    ). 

      
        C++     , ,   ,  
 ,   Object Pascal.    , 
         ,  
.       if,  Object 
Pascal        
 else. 

      
       C++      
  ({}). ,       
         begin  Object Pascal 
   end.      .  Object Pascal  
begin...end  o  oepaop.  C/C++   
     ,    
.  ,    C/C++   ,
  Object Pascal   ,    
   end.  C/C++ ,    
,   . 

      

      ,     . 
    ( ),  ,   
  ,     . 
     Object Pascal     : if  case.  
 if      ,  case   . 

     if...then 

    ,    ,   . 

    if boolean_axpression  then 
       statementl;  //       
                     //  statementl. 

    if boolean_expression then 
      statementl   
    else
      statement2;      //     statementl     statement2. 

      ,   if,  True,  
,   then.      False  
  else,  ,   else.  
  else  ,    if.  
   else  . 

       

           True  False. 
      True  False,    
          ,  
      . 

      

       ,  ,  ,   
 ,     . 
      . 

    	 

    Not	.   . Not True = False.   
		  
    And	 . X and Y = True,  X = True  Y = True 
    Or	 . X or Y = True,  X = True  Y = True 
    Xor	 . X xor Y = True,   X   Y  True 

     case...of 

     case       , 
      .    
  case (),    , 
        (  
case-),  -

    74	 I.   

 ,    else   , 
       . 

    case ordinal_expression  of    //      ,    
      1: statement1;               //  :   ; 
      2,3:  statement2;            //   :   ; 
    else  catchallstatement;	//      ; 
    end;//   

         .   
     . 
    Case-      ,   ,   
   .   ,   
,   .       
,  ,   else.   else 
,  ,    case. 

      
      case    C++   switch.   
  ,   ,  switch  
      ,    
 ,    .   
switch-    C/C++   break.

      
     SELECT CASE  Basic   case  Delphi. 


     

           ,  
 .  Object Pascal     . 

    for...to/downto...do 
    while...do 
    repeat...until 

             . 

    Break 		  for, while  repeat,    , 
			    
    Continue 	         


      
     break    C++   Break  Delphi.  , 
 C/C++  break     switch. 

      
     Basic  EXIT FOR  EXIT DO   Break  Delphi. 


     For...Do 

       ,   do,     
   ,    .  for 
  ,   ,     . 

    For controle_variable := initial_value To  final_value  Do  statement; 
    For controle_variable := initial_value Downto final_value Do  statement; 

      (controle_variable)    
  (initial_value).    ,    
,        ,  
       1.    Downto 
       ,   
     1. 

     3. Object Pascal:   75 

           .  
    ,     ,  
  . , ,   ,     
     . 
        ,     For  
   -  . 
            
     Do. 

     
     Delphi    For...Do ,   
    .     
  .  DO  FORTRAN, FOR   Basic  
for   C/C++  Delphi   While. . . Do. 


     Repeat...Until 

    ,   Repeat  Until,   
  ,  Until   True. 

    Repeat 
      statement1; 
      statement2; 
    Until boolean_expression; 

         Object Pascal,    
        
  (begin...end). 
       Repeat  Until   
 ,        . 

     
       C++    do... while (...},  Repeat...Until 
 Delphi,     .


    While...Do... 

     While      : 

    While boolean_expression Do statement; 

      While ,   Do,    
,     While  True.   
   .       
False,    . 

      
       C++  while (...)...    While...Do 
 Delphi. 

      
     Basic  WHILE...WEND    While...Do  Delphi. 


     With...Do 

              : 

    With record_variable Do statement; 

      With      ,  
  ,      . ,  
 - 

    var arecord : record  fieldl: integer; field2 : integer; end; 

        : 

    arecord.fieldl:=1; arecord.fieId2:=2; 
    with arecord do begin fieldl:=1; field2:=2; end; 


    76	 I.   

       .  With    
 ,    .     
,  .       
     ,     
   .   with     
   .	~ 

      
         ,    
With...Do. 


       

        ,       
.     ,   
 .   ,       
  . 
          procedure, 
 , ,   (  ). 
   ,     
  . 
         . 
         , , , 
  . 
    ,     (begin. . .end), 
      . 
    ,   ,      
   .     
  ,    ,  
  .        
 .       
function,  ,      
.      ,    
 ,     ,    
  . 
          , , , 
,   ,      
(begin...end),    ,     
 . 
            ,  
       
result (). 
     result        
    ,    .   result 
    . ,   
 ,      ( 
     ).   result    
, ,          , 
  .       
    ,   . 
             
.        
 (  )     ,   
 . 

   function  funcid(parameters) : typeid; //   , const  
   constid = consttant_expression;	       //  ,        
   type  typeid = type_definition;        //  ,       
   var : varl,  var2: type_definition;    //  . 
       //   , 
       //  ,   ,    
       //          
       //   , 
   procedure proc1; 
   procedure_definition; 
   function  funcl : typeid; 
   function_ definition; 
   begin 
     statements; 
     result: = typeid_expression; 
   end; 


     3. Object Pascal:   77 


       

      ,        
 ,           
  .      : 
     (  )  
    . 
     Object Pascal     .  
         .   
       "". 
  ,       ,  
     .     
    .  ,   
  Unit ,     (  
),         uses. 
              ,  
  .      , 
  .       
   . 

      

             
  .    (  )  
   .      
,        . 
       ,    
       .  
   ,      
    ,    
    . 

        

    ,   ,   , 
     . 

    parml, parm2 : atype;   //    ,    
                            //  . 

          . 
             
  ,        . 
            
,       ,  
(  )  . ,     
 . 

       

          var,   
    .  ,  
   ,       
     .   
      ,    
     !                                        
                                                                              
    var parml, parm2 : atype;  //   , 
                               //    . 

          -. 
              
  :       . 

    Const 

     -       
,      . 

    const parml, parm2 : atype;  // -  . 

         const .   
     var  . 

    78      I.   

          const 
  (,   ). 
              const 
 .       
,     const,    
,    ,   . 

       

         ,    
       .   
 var  const   ,      
 ,     . 

    var parml, parm2;      //  -    , 
    const  parml, parm2;   //   -     . 

       ( )    
,          . 
    ,         
   .     . 
           
,      . 

      

             
         . 

    var parml: array of atype;  //    . 

           ( 
 )       .  
     ,     
 : 

    var parml : array[0..N-1] of atype; 

     N    ,   , 
..        0..N-1. 
     .  
-  atype        atype. 
         ,   :  
     .    
  . 

     
             
      .   
 ,       .  
      (var  const).
       
             
  ,     .  
      ,   : 

    AverageThese([18.3, 19.8, 122.133, 3.43098V4]); 

       ,   ,   
,     .      
 ,   . 3.12. 

     3.12.      


       

    Low()       
    High()         
    SizeOf(A)   ( )   


     3. Object Pascal:   79 


      array of const 

      array of const    
         : 

    const parml : array of const; 

        ,    
    .     
array of const   array of TVarRec.  TVarRec    , 
   System. 
       TVarRec      
  array of const.   ,   
,    TVarRec.VType. 

     Delphi 

        . 

    unit unitid; //  , 
    interface //  . 
    uses 
      unitid2, unitid3; 
    const 
      constid = constant_expression; 
    type 
      typeid = type_definition; 
    var 
      varl: type_definition; 
    procedure proc1;         //     
    function fund : typeid;  //     
                             //   , 
    implementation           //  . 
    uses
      unitid, unitid2, unitid3; 
    const  
      constid = constant_expression; 
    type 
       typeid = type_definition; 
    var 
      varl, var2 : type_definition; 
    procedure prod; 
    procedure_block; 
    function func1 : typeid; 
    function_block; 
    initialization //  . 
      statements;  // ,    
                   // ;  , 
    finalization   //  . 
      statements;  // ,    
                   // ;  . 
    End.           //  . 


     

         ,   
     . 
           interface, 
   ,     
 implementation. 
       , , ,    
  ,        , 
  . 
           .  
   . 
        uses,      
  interface,    . 

    80  I.   


     

         , , ,   
   ,        . 
 ,       ,   
 . 
     ,     ,    
 . (       
   uses). ,    ,   
  . 
              
 .         . 
         uses,     
   implementation,    . 
     realization  
end. ( ). 

     

        .    
  initialization,    , 
    .     
   ,        uses . 
           ,  
   .      
       
, -        . 

     

      .  ,     
  .       
finalization,    ,    
.   (,   ..),     
 ,       
.         , 
     . 
         ,   
 , ..  ,     
 uses . 
        ,    
.     .  
      ,  
,    -      
. 

     

      Delphi  Object Pascal    
      .   Object 
Pascal    ,      
,      ,   
-  . 
        Object Pascal   .  
       ,  
   .      
  .       
  .      ,  
 . 
        . Object Pascal   
 (  )   , 
     . 
          
.        . 
          
(begin...end).      if...then 
 case...end.     for, while  repeat... until  
   . 
            .  
         
 .         
    ,      (  
 ). 
       ,       
 (unit),    .   
 ,      (  
  ,     ), 
,   . 
     ,      Object Pascal   
  ,    Delphi.     
   Pascal,   ,      Object 
Pascal.         , 
"Object Pascal:  ". 

     3. Object Pascal:   81 
