Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> record data structure with fields pp 79</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 RECORD                   Data Structure with Fields                  pp  79

 Syntax:  Name = Record

 Data:    All Types

 Type:    Declaration


 Purpose: Record creates a data structure made up of individual fields.


 Notes:   Each field is identified by a name unique to the record, and
          is given a data type.  The record fields are referenced
          by the construct NAME.FIELD, where Name is the record name,
          and Field is the field identifier.
          The record must be terminated by END ;



 Usage:
       TYPE
          Days   = 1..31               ;
          Months = (Jan,Feb,Mar,Apr,
                    May,Jun,Jul,Aug,
                    Sep,Oct,Nov,Dec)   ;
          Years  = 1900..1999          ;

          Date = Record
                 Day   : Days          ; { Day is 1..31 of Days        }
                 Month : Months        ; { Month is 1..12 of Months    }
                 Year  : Years         ; { Year is 1900..1999 of Years }
                 End                   ; { End of record               }

       VAR
          Birth        : Date          ;

       BEGIN
          Birth.Month  := Nov          ;  { Month field                }
          Birth.Day    := 4            ;  { Day field                  }
          Birth.Year   := 1950         ;  { Year field                 }
       END.

See Also: File Variant With

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson