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

4-5
---------------------------------------------------------------------------------------------
| | |
| Default type: LOGICAL | Default type: int (= long int) |
| | |
---------------------------------------------------------------------------------------------
| | |
| Array declarations specify one-dimensional | Same as SPL. |
| vectors of subscripted variables. | |
| | |
---------------------------------------------------------------------------------------------
| | |
| Array subscript declarations and references | Array subscript declarations and references |
| use parentheses, "( )" | use brackets, "[ ]" |
| | |
---------------------------------------------------------------------------------------------
| | |
| An array identifier with no subscript | An array identifier with no subscript is a |
| implies a subscript of zero. It is |
pointer
to cell zero. It is
not
equivalent |
| equivalent to
array-id
(0). | to
array-id
[0]. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Array declarations which allocate space may | The lower bound of HP C/XL arrays is always |
| specify a lower bound other than zero, | zero. |
| subject to certain restrictions. | |
| | Therefore, the HP C/XL zero subscript |
| Therefore, the SPL zero subscript may refer | always refers to the "first" (lower bound) |
| to some cell other than the lower bound, or | cell of the array. |
| to a location outside the array. | |
| | |
---------------------------------------------------------------------------------------------
| | |
| Indirect array-ids are equivalent to | Array-ids are identical to pointers in |
| pointers. They may be changed to point to | computations, except that the pointer value |
| a new cell zero location. | of an array-id cannot be changed. That is, |
| | it will always point to cell zero of the |
| Direct array-ids are the location of cell | declared array. |
| zero. Their locations cannot be changed. | |
| | However, HP C/XL pointers may be |
| | subscripted and used like array-ids, |
| | allowing them to act like SPL indirect |
| | array identifiers. |
| | |
---------------------------------------------------------------------------------------------
In HP C/XL, if A is an array-id and P is a pointer-id and P=&A[0], then
the following equivalences exist:
A == &A[0] == P == &P[0]
*A == A[0] == *P == P[0]
*A+1 == A[0]+1 == *P+1 == P[0]+1
*(A+1) == A[1] == *(P+1) == P[1]
This situation simplifies some of the conversion necessary for changing
SPL procedure calls to HP C/XL function calls. If an unsubscripted HP
C/XL array-id is passed to a function, it is passed by value as a
pointer
to the array. This is identical to passing cell zero by reference, the
equivalent code in SPL. Therefore, conversion is minimal for full arrays
passed by reference. To pass a specific cell by reference, convert the
SPL cell reference, "
id
(
cell
)", to the HP C/XL address format,
"&
id
[
cell
]".
Summary of SPL Array Formats
1a. Indirect; bounded; variable is pointer to cell zero; pointer in
next DB primary location; pointer IS allocated; array begins in