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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Structures, Unions and Records<br />

PARAMETER (MAX_ELS=1000)<br />

STRUCTURE /OBJECT/<br />

REAL SIZE<br />

INTEGER WEIGHT<br />

CHARACTER*2 COLOUR<br />

END STRUCTURE<br />

RECORD /OBJECT/ ITEM(MAX_ELS)<br />

To read or write the attributes relating to an object, you would use a statement such as:<br />

READ(UNIT=3) ITEM(I)<br />

6.3 Unions<br />

Sometimes it is useful to be able to describe parts of structures in different ways in much the same way that<br />

the EQUIVALENCE statement is used to describe a specific storage area in different ways. The UNION -<br />

END UNION statements are used to mark a section of a structure that will have alternate storage<br />

organizations (MAPs). The MAP - END MAP statements are used to define the start and end of an alternate<br />

storage map. Thus several MAP - END MAP pairs will appear between a UNION - END UNION section.<br />

Consider the following example. The subroutine displays the contents of a field using different names and<br />

formats depending on a TYPE field.<br />

Example:<br />

Unions 169

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

Saved successfully!

Ooh no, something went wrong!