[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
type                     Signals the Start of a Set of Type Declarations

 type
   <tname>   = <oldtype>;
   <tname>   = <low>..<high>;
   <tname>   = (<item1>,<item2>,...,<itemN>);
   <tname>   = <filetype>;
   <tname>   = <settype>;
   <tname>   = <arraytype>;
   <tname>   = <recordtype>;

    The TYPE section is used to declare your own data types, by renaming
    existing data types, naming subranges of existing ordinal data types,
    creating enumerated data types, or defining array-, record-, or set-
    based data types. Types declared in a subprogram are local to that
    subprogram; those declared in the main program are global from the
    point of their declaration to the end of the program.

         <tname>    Name of data type being defined.

       <oldtype>    Any previously declared or predeclared data type.

    <low>,<high>    Any two values of the same ordinal (Integer, Char,
                    Boolean, enumerated) type. <low> must be less than or
                    equal to <high>.

   <item1>, etc.    A list of standard identifiers, naming the different
                    values of an enumerated data type. All the identifiers
                    must be unique and not previously declared.

      <filetype>    Any legal FILE declaration.

       <settype>    Any legal SET declaration.

     <arraytype>    Any legal ARRAY declaration.

    <recordtype>    Any legal RECORD declaration.

    In Standard Pascal, you can have at most one TYPE section per program
    or subprogram (procedure, function), and it must appear after the
    CONST section and before the VAR section. Turbo Pascal allows you to
    have multiple TYPE sections per program or subprogram and requires
    only that they appear before (and outside of) the main body of that
    program or subprogram.

  -------------------------------- Example ---------------------------------

           type
             Days      = (Sun,Mon,Tues,Wed,Thur,Fri,Sat);
             CharSet   = set of Char;
             WeekDay   = Mon..Fri;
             Nibble    = 0..15;
             NameStr   = string[20];
             SSStr     = string[9];
             NumList   = array[1..1000] of Integer;
             StudPtr   = ^Student;
             Student   = record
               Last,First : NameStr;
               SSN        : SSStr;
               GPA        : Real
             end;

See Also: file set array record var procedure function
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson