Previous Topic Next topic Print topic


BYVALUE

Note: VALUE is accepted as a synonym for BYVALUE.

BYVALUE can be used as an attribute in an ENTRY declaration, or can be applied to a parameter.

The BYVALUE attribute may only be applied to a parameter and parameter descriptors of the following types:

Fixed Binary(n)     where n ≤ 31    
Float Binary(n) where n ≤ 23 (when calling PL/I)
Float Binary(n) where n ≤ 52 (when calling non-PL/I)
Aligned Bit(n) where n ≤ 32
Character  
Pointer  
Entry  

The BYVALUE attribute is ignored if it is applied to a variable that is not a parameter.

If a parameter is multi-positional (appears in one or more of the PROCEDURE and ENTRY statements in a particular procedure) it may not have the BYVALUE attribute applied to it.

When a procedure is called from an Open PL/I procedure, the BYVALUE attribute should be applied only to a parameter whose corresponding parameter descriptor was also declared with BYVALUE in the calling procedure's ENTRY declaration in the called procedure. For example:

P: PROCEDURE( A, B, Q);
DECLARE
   A FIXED BIN(31) BYVALUE,
   (B,C) FIXED BIN(15),
   Q POINTER BYVALUE,
   X FIXED BIN(15) BASED (Q);
B = A + 2; 
A = 2 * B; 
C = X;
ALLOCATE X SET(Q);
X = A + C; 
END;

In this example, the value passed by A is incremented by 2 and returned to the calling procedure through B. The assignment of 2 * B to A does not affect the calling procedure; the value of the first argument of the CALL is unchanged by the assignment to A in the called procedure. Similarly, the value of the argument in the calling procedure that corresponds to Q is not changed by the ALLOCATE statement.

Previous Topic Next topic Print topic