SPL to HP C/XL Migration Guide (30231-90001)

4-9
Array Formats 7a and 8: Unbounded Equivalenced Arrays.
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| DOUBLE ARRAY EFG(0:25); | long int EFG[26]; |
| | |
| ... | ... |
| | |
| 7a. REAL ARRAY ABC(*) = EFG; | float *ABC = &EFG[0]; |
| | |
| 8. DOUBLE ARRAY ABC(*) = EFG(0); | #define ABC EFG |
| | |
| 8. REAL ARRAY ABC(*) = EFG(10); | float *ABC = &EFG[10]; |
| | |
---------------------------------------------------------------------------------------------
SPL assigns the
same
pointer location to ABC and EFG: if EFG is indi-
rect, if the index of EFG is zero, and if the type of both arrays or
neither is BYTE. HP C/XL allows you to simulate this with a #define only
if both arrays are of the identical type. Otherwise, you must use a
union data type.
Array Formats 2b and 3b: Unbounded Equivalenced Arrays.
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| 2b. INTEGER ARRAY DEF(@) = DB + 10; | short int DB[256]; |
| | ... |
| | short int *DEF = &DB[10]; |
| | |
| 3b. REAL ARRAY ABC(*) = DB + 10; | union |
| | { |
| | short int DB[256]; |
| | struct |
| | { |
| | short int dummy[10]; |
| | float ABC_REF[1]; /*cell zero*/ |
| | } |
| | } |
| | float *ABC = &ABC_REF[1]; |
| | |
---------------------------------------------------------------------------------------------
In SPL, two types of arrays may be equated to the DB-relative area:
indirect arrays, in which one word of the DB area is allocated to be used
as a pointer to an array; and direct arrays, in which the name of the
array refers to the next element of the DB area, which is assumed to be
cell zero of an array actually contained within this (DB-relative) area.
If DB-relative addressing is required for an SPL application and cannot
be rewritten in a straightforward manner, a DB area may be simulated in
HP C/XL.
In the first example, the DB area is simulated as a short int array. The
value of the pointer DEF is set to the value in DB[10]. DEF is an
indirect array.