SPL to HP C/XL Migration Guide (30231-90001)
6-10
| | Fortunately, because SPL is so strict, the |
| | conversion boils down to getting the |
| | pass-by format correct. |
|| |
---------------------------------------------------------------------------------------------
Table 6-14. Procedure Call Statement Examples
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| PROCEDURE P1 ( VALP ); | void P1 ( VALP ) |
| VALUE VALP; INTEGER VALP; | unsigned short VALP; |
| BEGIN | { |
| GVAR := VALP; | GVAR = VALP; |
| END; | } |
| | |
| PROCEDURE P2 ( REFP ); | void P2 ( REFP ) |
| INTEGER REFP; | unsigned short *REFP; |
| BEGIN | { |
| GVAR := REFP; | GVAR = *REFP; |
| END; | } |
| ... | ... |
| <<main program>> | /*main function*/ |
| ... | ... |
| P1(V); <<pass-by-value>> | P1(V); /*pass-by-value*/ |
| P2(V); <<pass-by-reference>> | P2(&V); /*pass-by-reference*/ |
| ... | ... |
| | |
---------------------------------------------------------------------------------------------
In the examples above, notice that when P2 was called (in HP C/XL), the
address
of the variable was explicitly specified with the "&" operator.
If the actual parameter had been an unsubscripted array-id or a string
literal, the "&" would have been omitted. In HP C/XL, if an identifier A
is declared to be an array, the following function call expressions are
equivalent:
P3(A);
and
P3(&A[0]);
The data type void specifies that the function does not return a value.
See "PROCEDURE Declaration" for details.
String Literals
HP C/XL allows string literals to be passed as actual parameters, which
is not possible in SPL. Thus, the following SPL code
MOVE BARRAY:="test string";
PROCB(BARRAY); <<called with byte array BARRAY>>
used to pass a string to an SPL procedure via a byte array, may be
rewritten in HP C/XL as:
PROCB("test string");
HP C/XL will create storage for the string, and pass its address to PROCB
as a "pointer to char" (a byte address). This is a more straightforward