ITPub博客

首页 > 数据库 > Oracle > fortran union map用法

fortran union map用法

Oracle 作者:rainyyao88 时间:2014-03-12 08:03:26 0 删除 编辑

UNION and MAP

The UNION @ statement defines groups of fields that share memory at runtime.

The syntax of a UNION declaration is as follows:



UNION
       MAP
              field-declaration
              field-declaration
              ...
       MAP
              field-declaration
              field-declaration
              ...
       END 
MAP
END UNION

 

Description

A MAP statement defines alternate groups of fields in a union. During execution, one map at a time is associated with a shared storage location. When you reference a field in a map, the fields in any previous map become undefined, and are succeeded by the fields in the map of the newly referenced field. Also:

  • A UNION declaration can appear only within a STRUCTURE declaration.

  • The amount of memory used by a union is that of its biggest map.

  • Within a UNION declaration, the order of the MAP statements is not relevant.

The UNION line is part of an inherently multiline group of statements, and neither the UNION line nor the END UNION line has any special indication of continuation. You do not put a nonblank in column six, nor an & in column one.

Each field-declaration in a map declaration can be one of the following:

  • Structure declaration

  • Record

  • Union declaration

  • Declaration of a typed data field

Example

Declare the structure /STUDENT/ to contain either NAME, CLASS, and MAJOR, or NAME, CLASS, CREDITS, and GRAD_DATE:



       STRUCTURE /STUDENT/ 
       CHARACTER*32  NAME 
       INTEGER*2  CLASS 
       UNION 
              MAP 
                     CHARACTER*16 MAJOR 
              END MAP 
              MAP 
                     INTEGER*2  CREDITS 
                     CHARACTER*8  GRAD_DATE 
              END MAP 
       END UNION 
       END STRUCTURE 
       RECORD /STUDENT/ PERSON 

 

In the above example, the variable PERSON has the structure /STUDENT/, so:

  • PERSON.MAJOR references a field from the first map; PERSON.CREDITS references a field from the second map.

  • If the variables of the second map field are initialized, and then the program references the variable PERSON.MAJOR, the first map becomes active, and the variables of the second map become undefined.

from: http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbl/index.html
<!-- 正文结束 -->

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23260549/viewspace-1115853/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-01-29