Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Pascal/HP-UX Programmer's Guide > Chapter 7 Parameters

READONLY Parameters

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

A READONLY parameter is similar to a value parameter in that the routine cannot directly modify its actual parameter, which can be a constant, an expression, or a variable. READONLY differs from a value parameter in that the routine cannot modify the formal parameter: you cannot assign a value to the formal READONLY parameter, pass it to a VAR or ANYVAR parameter, or pass it to either of the predefined functions addr, baddress, or waddress.

A READONLY parameter is similar to a VAR or ANYVAR parameter in that its actual parameter is passed by reference. If the actual parameter is an expression or constant, a copy of its value is passed by reference.

Example

PROGRAM prog;
$STANDARD_LEVEL 'HP_MODCAL'$

TYPE
arraytype = ARRAY [1..10] OF integer;

CONST
arrayconst = arraytype [10 OF 0];

VAR
arrayvar : arraytype;

FUNCTION arrayfunc : arraytype; EXTERNAL;

PROCEDURE p ( valuep : arraytype;
VAR varp : arraytype;
READONLY readonlyp : arraytype); EXTERNAL;

BEGIN
p(arrayconst, {value is passed}
arrayconst, {illegal must be a variable}
arrayconst); {address of copy of value is passed}

p(arrayvar, {value is passed}
arrayvar, {address is passed}
arrayvar); {address is passed}

p(arrayfunc, {value is passed}
arrayfunc, {illegal must be a variable}
arrayfunc); {address of copy of value is passed}
END.

The comments in the preceding program explain the differences in passing a constant (arrayconst), a variable (arrayvar), and an expression (a call to the function arrayfunc) to a value parameter (valuep), a VAR parameter (varp), and a READONLY parameter (readonlyp).

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.