Using INONLY, INOUT and OUTONLY

Unless an argument is declared with the attribute INONLY or OUTONLY, the argument is INOUT and is presumed to have a value before it is passed and to be changed (possibly) by the called code.

When you declare an argument as INONLY, then the argument is presumed to have a value before it is passed but not to be changed by the called code. Hence a dummy argument would never need to be created for such an argument.

When you declare an argument as OUTONLY, then the argument is presumed not to have a value before it is passed but to be set by the called code.

The BYVALUE attribute implies the INONLY attribute. Hence the attributes OUTONLY and BYVALUE conflict and may not both be specified for the same argument. However, the ASSIGNABLE attribute is allowed with the BYVALUE attribute.

The explicit use of these attributes makes your code more self-documenting. Furthermore, it allows the compiler to produce better code and to be more accurate in reporting possibly uninitialized variables.

Passing a variable that has the INONLY attribute as an argument to an entry when the corresponding parameter has the INOUT or OUTONLY attribute allows the variable to be modified which would make the code invalid. For example, the following code could lead to a protection exception:

     call test( 17 );

     test: proc( x );
       dcl x fixed bin(31) INONLY;
       dcl e ext entry( INOUT fixed bin(31) );
       call e(x);
     end;