[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
Alignment directives offer flexibility and selectivity: they alter the current alignment by specifying new alignment information from within the source program.
The forms of the alignment directives are as follows:
*DC SET ALIGNMENT *DC SET NOALIGNMENT *DC END-SET ALIGNMENT *DC SET PADALIGN *DC SET NOPADALIGN *DC END-SET PADALIGN |
The *DC SET ALIGNMENT directive and the *DC SET PADALIGN directive function independently of each other, except when their scopes overlap in the program source. In case of overlapping scope, the effect of the *DC SET PADALIGN directive prevails.
The *DC SET ALIGNMENT directive specifies natural Alpha alignment of elementary data items. The *DC SET PADALIGN specifies Alpha natural alignment and padding.
The *DC SET NOALIGNMENT directive specifies OpenVMS VAX compatible alignment.
The optional *DC END-SET ALIGNMENT directive terminates the current *DC SET ALIGNMENT or *DC SET NOALIGNMENT directive that is currently in effect.
The alignment of binary data that has been specified with the SYNCHRONIZED clause is unaffected by the *DC SET ALIGNMENT and *DC SET PADALIGN directives.
When you use an alignment directive or qualifier to align data in records, you should consider whether the data will be written to a file to be accessed by applications written in HP COBOL for OpenVMS VAX.
These directives are not allowed in the PROCEDURE DIVISION of a program source. |
Table 16-2 shows the order of precedence of the primary alignment qualifiers and directives in HP COBOL.
Compiler Directives | ||||
---|---|---|---|---|
Command line Qualifier and Option |
No Directive in Effect |
*DC SET ALIGNMENT |
*DC SET PADALIGN |
*DC SET NOALIGN |
(none) | None |
Align
elementary data items. |
Align and pad elementary data items and structures. | None |
/ALIGNMENT
-align |
Align
elementary data items. |
Align
elementary data items. |
Align and pad elementary data items and structures. | None |
/ALIGN=PAD
-align pad |
Align and pad elementary data items and structures. | Align elementary data items and structures. | Align and pad elementary data items. | None |
Alignment directives located within the source program alter the current alignment by specifying a new alignment, which remains in effect (except for data specified with SYNCHRONIZED, which remains unchanged) until changed precedence, or until the beginning of the next file specified in a comma list. You can nest alignment directives within a program to specify different alignments for selected sets of data. Alignment directives do the following:
Example 16-1 shows an example of nested alignment directives in source code.
Example 16-1 Using*DC SET ALIGNMENT Directives |
---|
. . (1) . *DC SET ALIGNMENT (2) 01 comp-group. 02 cg-x1 pic x. 02 cg-c1 pic 9(1) comp. *DC SET NOALIGNMENT (3) 01 comp-group-2. 02 cg-x2 pic x. 02 cg-c2 pic 9(1) comp. *DC END-SET ALIGNMENT (4) 01 comp-group-3. 02 cg-x3 pic x. 02 cg-c3 pic 9(1) comp. *DC END-SET ALIGNMENT (5) 01 comp-group-4. 02 cg-x4 pic x. 02 cg-c4 pic 9(1) comp. |
The SYNCHRONIZED clause, which aligns binary data on natural
boundaries, is included in both HP COBOL and HP COBOL for OpenVMS VAX.
Refer to the HP COBOL Reference Manual for complete information on the
SYNCHRONIZED clause.
16.4.3 Comparing Alignment Directive Effects
The alignment examples that follow illustrate the following important points:
Example 16-2 through Example 16-6 show a comparison of the use and results of several alignment cases. They are applicable to Tru64 UNIX, OpenVMS I64 and OpenVMS Alpha; and Example 16-2 is additionally applicable to OpenVMS VAX (except for the information on the /ALIGNMENT qualifier, which is Alpha- and I64- specific). Example 16-2 shows the effects of the SYNCHRONIZED clause in program source, as compared with the /ALIGNMENT qualifier on the command line.
Example 16-2 Using /ALIGNMENT with SYNCHRONIZED |
---|
01 comp-group. 02 cg-x1 pic x. (1) 02 cg-c1 pic 9(1) comp. (2) 02 cg-c3 pic 9(3) comp. (3) 02 cg-c7 pic 9(7) comp. (4) 02 cg-c12 pic 9(12) comp. (5) 01 comp-group-synch. 02 cg-x1-synch pic x. (6) 02 cg-c1-synch pic 9(1) comp synchronized. (7) 02 cg-c3-synch pic 9(3) comp synchronized. (8) 02 cg-c7-synch pic 9(7) comp synchronized. (9) 02 cg-c12-synch pic 9(12) comp synchronized. (10) |
The data is aligned as shown in the following examples using different alignment configurations. In the accompanying data diagrams, a number (n) indicates that that byte is occupied by the nth field of the record, and a dash (---) indicates a filler byte. The fields are indicated by the callouts in the right column of Example 16-2.
HP COBOL for OpenVMS VAX would align the data as follows:
| | | | | 1111 | 1111 | | 1223 | 3444 | 4555 | 5555 | 5 | 6-77 | 88-- | 9999 | ---- | 0000 | 0000 | | |
Previous | Next | Contents | Index |