SPL to HP C/XL Migration Guide (30231-90001)
4-7
zero; cell zero in specified location; array NOT allocated.
Indirect (if
ref-id
is pointer or indirect array); unbounded;
variable is pointer to cell zero; cell zero in specified location;
pointer in next DB primary location IF specified location is not
ref-id
cell zero OR IF one array is BYTE and other is not; ELSE
pointer location shared with
ref-id
; pointer IS allocated; array
NOT allocated.
Array formats 2, 3, 4, 5, 6, 7, and 8 imply methods of data equivalencing
or "overlays".
Array formats 4, 5, 6, 7, and 8 cannot have the GLOBAL attribute.
Only array formats 1c and 1d may be initialized.
Comparison of Specific Array Declarations
Array Formats 1a and 1c: Bounded Indirect Arrays.
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| 1a. INTEGER ARRAY ABC(0:4) ; | short int ABC_REF[5]; |
| | short int *ABC = &ABC_REF[0]; |
| | |
| 1a. INTEGER ARRAY ABC(-3:4) ; | short int ABC_REF[5]; |
| | short int *ABC = &ABC_REF[3]; |
| | |
| 1c. INTEGER ARRAY ABC(0:4) := 0,1,2,3; | short int ABC_REF[5]={0,1,2,3}; |
| | short int *ABC = &ABC_REF[0]; |
| | |
| 1c. INTEGER ARRAY ABC(-3:4) := 6,2,5; | short int ABC_REF[8]={6,2,5}; |
| | short int *ABC = &ABC_REF[3]; |
| | |
---------------------------------------------------------------------------------------------
These are SPL "indirect" arrays. In SPL, the location labeled ABC is a
pointer that contains the address (initially) of the zero cell of the
array's data.
By converting the SPL indirect array identifier ABC to HP C/XL pointer
ABC, all the operations (such as assigning a new address) that may be
performed on the SPL array identifier may be performed on the HP C/XL
pointer identifier. The HP C/XL pointer may be subscripted to reference
array cells.
If the SPL lower bound is zero and the array identifier is not modified,
you may use the direct format, as shown below.
The examples above with the nonzero lower bounds show the solution to the
SPL capability to specify non-zero lower bounds. Subscripting ABC from
-3 through 4 will access the eight cells of ABC_REF from 0 through 7.