delphi type


         1. type Name = Existing type;

   2. type Name = type Existing type;
   3. type Name = (EnumValue1 [=value], EnumValue2 [=value] ...);
   4. type Name = Expression1..Expression2;
   5. type Name = ^Existing type;
   6. type Name = array[...] of Existing type;
   7. type Name = class ... end;
   8. type Name = class of Existing class
   9. type Name = dispinterface ... end;
  10. type Name = file of Existing type;
  11. type Name = function ...;
  12. type Name = interface ...  end;
  13. type Name = object ... end;
  14. type Name = procedure ...;
  15. type Name = record ... end;
  16. type Name = set of Ordinal values

Description: Type keywords is a fundamental part of Delphi, unlike other languages, it allows a new type (species) to create variables and procedures. These new types can be referenced, as if it were part of the language.

For example: Type TCourtCards = (Ace, Jack, Queen, King);

This allows the definition of a "type" new variable: var Card: TCourtCard; Card: = Queen;

Prefix generally in the type name plus "T", which is a useful convention.

1.type Name = Existing type

With reference to a conventional type, such as to replace with a new name string.

2.type Name = type Existing type

The same effect as above, but it ensures that at run time, this type of variable it is recognized as a new type name, rather than pre-existing type name.

3.type Name = (EnumValue1,EnumValue2…)

Definition of an enumerated type, contains the value EnumValue1, EnumValue2 like. It is a user-defined name, list all possible values. These values ​​must be unique in your program, once it is defined in the type, it can only be referenced by two methods: a designation or reference variable of this type; and a sequence number acquired as a digital value by Ord keywords. See examples.

NOTE: These elements, when the definition of the enumeration, its position is 1, 2, etc., unless the value "= value" overwrite. Such as:

Type Days = (Monday = 1,Tuesday,Wed…);

Here, the position value is set catalog on Monday 1, Tuesday is 2, Wednesday 3, and so on.

4.Type Name = Expression1..Expression2

Here is a complete range of integers or characters, from Expression1 expression to Expression2 expression. Expressions 1 and 2 may be the result of a formula calculation result of an integer or a character, or only an integer or character constant. Such as: Type TAlphabet = 'A' .. 'z'; commonly used to define a range of characters, from uppercase to lowercase A z.

5.type Name = ^Existing type

'^' Symbol is a pointer pointing to the conventional type. It is often used for navigation Record type records.

6.type Name = array[…] of existing type

A structure type, new type of package with a certain type of the array.

7.type Name = class…end

Defines the structure of a new class, see Class keyword.

8.type Name = class of existing class

A meta-class definitions, see Class keyword.

9.type Name = dispinterface … end

A dispatch Interface (dispatch interface) type, see Dispinterface keywords.

10.type Name = file of Existing type

A pointer to the type of the file, the file contains records of the given type. (By default, the file contains binary data)

11.type Name = function …

It is defined as a function type, to allow this function is defined as parameters for the subroutine.

12.type Name = interface … end

It is used to define the structure of the interface. See Interface keyword.

13.type Name = object … end

Equivalent to the class definition has been obsolescence.

14.type Name = procedure …

It is defined as a type of process, to allow this process is defined as parameters for the subroutine.

15.type Name = record … end

Recording type, given under the name of the package data structure. See Record keywords.

16.type Name = set of Ordinal values

The number of sub-sector defined order. It defines the range of integers or characters. See Set keyword.


Some examples cited type {} 
the Type 
  TString1 = String; // the Name = 1. Existing type type 
  TString2 = String type; // the Name type = type 2. Existing type 
  TTemp = (Hot, Warm, Cold); // 3. type = name (Enum1, Enum2 ...) 
  TExpr = 2. 5 .. * *. 6. 3; // type name = 4. Expr1 .. Expr2 
                                // 5. The keyword See the Pointer The 
  TArray = Array [1..3] of byte;.. 6 // Array type the Name = [...] of type 
                                  // see TFrom1 7. The class definition 
                                  // 8. see class Image 
                                  @ 9. see Dispinterface keyword  
                                  @ 10. see File Key words
                                  // Function 11. see Key words 
                                  // Image Interface 12. See 
                                  @ 13 out without the 
                                  @ See Procedure 14. Image 
  trecord = Record the Name = @ 15. A type .. End Record; 
      header : String; 
      value: Integer; 
  TLetters of SET = 'a' .. 'Z'; // 16. a type of the Name = SET ordinals 
  // variables with defined above type 
  firstName: TString1; 
  lastName: TString2; 
  temperature : TTemp; 
  expression The: TExpr; 
  the myArray: TArray; 
  MyRecord: trecord; 
  Letters: TLetters; 
the begin 
  // assign a variable 
  firstName: = 'Neil';
  lastName        := 'Moffatt';
  temperature     := Cold;
  expression      := 10;
  myArray[1]      := 5;
  myRecord.header := 'data file';
  letters         := ['F'..'Q'];

Guess you like