HP Pascal/iX Programmer's Guide (31502-90023)

10: 6
| | Bit32 | |
| | Bit52 | |
| | Integer | |
| | Integer Subrange | |
| | Longint | |
| | Record | |
| | Set | |
| | Shortint | |
| | | |
-----------------------------------------------------------------------------------------------
Function and Procedure Parameter Compatibility.
A
function
or
procedure parameter
is a parameter that is a routine. The
compiler only checks that the actual parameter for a function or
procedure parameter is a routine. You are responsible for making sure
that the actual parameter is what the intrinsic expects.
Using Strings as Actual Parameters.
If you use a string variable as an actual value parameter to an intrinsic
routine, HP Pascal passes a copy of the
data portion
only of the string.
The length portion is ignored.
If you use a string variable as an actual reference parameter to an
intrinsic routine, HP Pascal passes the address of the
data portion
of
the string, and not the string length. If the intrinsic returns data in
the string variable, you must determine and update the length of the
string when the intrinsic returns control to your program.
There are a number of ways to obtain and update the string length:
* If the intrinsic returns the correct length as a parameter or
function return, use the setstrlen procedure with the returned
value.
* If the length is defined in documentation of the intrinsic, use
the setstrlen procedure with that value.
* If the intrinsic appends some end-of-string character (such as
NUL), scan for the character and set the string length with the
setstrlen procedure to one less than the character's position.
* If the intrinsic does not provide any length indication, you can
use the strrpt function to fill the string with blanks to its full
physical length, call the intrinsic, and then use the strrtrim
function to get rid of the trailing blanks and update the string
length.
Example
This example demonstrates the sequence of filling a string with blanks,
calling an intrinsic that returns a value in the string, and updating the
string length.
PROGRAM TestIntrin ;
VAR
Str : string [80] ;
PROCEDURE Dateline ; INTRINSIC ;
BEGIN { main program }
...
Str := strrpt ( ' ' , 80 ) ; { fill string with blanks }
Dateline ( Str ) ; { call intrinsic }
Str := strrtrim ( Str ) ; { remove trailing blanks }
...
END .
Formal and Intrinsic Function Type Compatibility