24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Language</strong> <strong>Reference</strong><br />

2.78 STRUCTURE Statement<br />

STRUCTURE /typename/<br />

where:<br />

typename<br />

is the name for a new, compound variable, data type.<br />

The STRUCTURE statement is used in conjunction with the END STRUCTURE declarative statement. The<br />

STRUCTURE statement marks the start of a structure definition.<br />

The STRUCTURE statement defines a new variable type, called a structure. It does not declare a specific<br />

program variable. The RECORD statement is used to declare variables and arrays to be of this particular<br />

structure type.<br />

Structures may be composed of simple <strong>FORTRAN</strong> types or more complex structure types. This is shown<br />

in the following example.<br />

Example:<br />

STRUCTURE /ADDRESS/<br />

CHARACTER*20 STREET<br />

CHARACTER*20 CITY<br />

CHARACTER*20 STATE<br />

CHARACTER*20 COUNTRY<br />

CHARACTER*10 ZIP_CODE<br />

END STRUCTURE<br />

STRUCTURE /PEOPLE/<br />

CHARACTER*20 NAME<br />

RECORD /ADDRESS/ ADDR<br />

INTEGER*2 AGE<br />

END STRUCTURE<br />

RECORD /PEOPLE/ CUSTOMER<br />

Element names are local to the structure in which they appear. The same element name can appear in more<br />

than one structure. Nested structures may have elements with the same name. A particular element is<br />

specified by listing the sequence of elements required to reach the desired element, separated by percent<br />

symbols (%) or periods (.).<br />

Example:<br />

CUSTOMER%NAME = ’John Doe’<br />

CUSTOMER%ADDR%STREET = ’22 Main St.’<br />

CUSTOMER%ADDR%CITY = ’Smallville’<br />

CUSTOMER%ADDR%STATE = ’Texas’<br />

CUSTOMER%ADDR%COUNTRY = ’U.S.A.’<br />

CUSTOMER%ADDR%ZIP_CODE = ’78910-1203’<br />

CUSTOMER%AGE = 23<br />

For more information, see the chapter entitled "Structures, Unions and Records" on page 167.<br />

140 STRUCTURE Statement

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!