Derived Data Types - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Derived Data Types

Description:

How Do You Create, Declare & Use User-defined Datatypes ... You may declare both individual as well as arrays of the datatypes. ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 10
Provided by: paulmc4
Category:
Tags: data | declare | derived | types

less

Transcript and Presenter's Notes

Title: Derived Data Types


1
Derived Data Types
  • User Defined Data types for Creating Structures

2
Derived Datatypes
  • While arrays allow you to store and process
    related data of the same type as one item. This
    is not possible when different datatypes are
    required.
  • By building new datatypes using either intrinsic
    or previously defined datatypes we can create an
    infinite variety of structures to hold
    information we need.

3
How Do You Create, Declare Use User-defined
Datatypes
  • Before you can use a User-defined datatype you
    must do two things in the following order
  • Define what the datatype is using already defined
    datatypes (intrinsic or user-defined).
  • Allocate Memory (Static or Dynanamically) to hold
    the information in the structure the user has
    defined.

4
Definition of a Derived Type
  • TYPE type_name
  • declaration1
  • declaration2
  • . . .
  • declarationn
  • end TYPE type_name

5
An Example of a Student Record
  • TYPE student_record_t
  • character(20) Fname, Lname, MI(1)
  • integer id_number, credits_attempted
  • double precision gpa
  • character(25) street, city, state(2)
  • integer zipcode
  • END TYPE student_record_t

6
Defining a Structure
  • Note that the order in which the various fields
    are declared is important. It is the default
    order of the fields in the structure.

7
Declaring Structures
  • This is the process of allocating memory for user
    defined datatypes.
  • You may declare both individual as well as arrays
    of the datatypes. It is done in the following
    manner
  • TYPE (student_record_t) my_record
  • or
  • TYPE(student_record_t),dimension(90) class

8
Accessing Components
  • To access a specific component of a user defined
    datatype you use the component selector character
    () along with the variable name.
  • my_recordLname McNally
  • my_recordid_number 123456789

9
Reading A User Defined Datatype
  • Read(10,15,iostatck_var)My_record
  • If (ck_var /0 ) stop error reading
  • Do loop 1, 90
  • read (10,15,iostatck_var) class (loop)
  • If (ck_var /0 ) stop error reading
  • End do
  • 15 Format(A20,A20, A1, I9, I3,F4.2,A25,
    A25,A2,I5)
Write a Comment
User Comments (0)
About PowerShow.com