FORTRAN 77 Language Reference

Structure within a Structure

You can nest a declaration within a declaration.

Example: If /PRODUCT/ is not declared previously, then you can declare it within the declaration of SALE:


	STRUCTURE /SALE/ 
			CHARACTER*32  BUYER 
			INTEGER*2  QUANTITY 
			STRUCTURE /PRODUCT/ ITEM 
				INTEGER*4  ID 
				CHARACTER*16  NAME 
				CHARACTER*8  MODEL 
				REAL*4  COST 
				REAL*4  PRICE 
			END STRUCTURE 
	END STRUCTURE 

Here, the structure SALE still contains the same three fields as in the prior example: BUYER, QUANTITY, and ITEM. The field ITEM is an example of a field-list (in this case, a single-element list), as defined under "Structure Declaration."

The size and complexity of the various structures determine which style of substructure declaration is best to use in a given situation.