PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Parameter Passing with OPTIONS keyword

Go down

Parameter Passing with OPTIONS keyword

Post  maran on Sat Aug 11, 2012 1:39 am

Parameter Options

When you define parameters for a subprocedure, you have a number of options to make the application more usable and functional. These options are defined using the OPTIONS keyword on the parameter definition in both the procedure interface and the prototype definition.
The option keywords are defined within parentheses following the OPTIONS keyword as follows:
D Variable nn OPTIONS(option_value)

The options that are currently available as follows:
*VARSIZE – This option lets you pass variables of different lengths into this subprocedure. For example, if you have a parameter defined as 100 characters and you want to use a variable defined as 20 characters as a parameter, using the *VARSIZE option lets you do it. Remember that when you use this option, you must have a way to determine the length of the data passed in. You can only work with that amount of data. (You usually pass another value containing the length or use operational descriptors.)

*NOPASS – With this option, you can specify that a particular parameter is not required to be passed on the call. All parameters following the first defined with the *NOPASS option must also be specified as *NOPASS. It is important to program for the possibility of a parameter using the *NOPASS option. Normally you can use the %parms built-in function to obtain the number of parameters that were used.

*OMIT – This option tells the compiler that the special value of *OMIT may be used as the value of the parameter, which should tell the called procedure that this particular parameter has been omitted. This option is useful if you have an option parameter, but the following parameters are required. This option is only available for parameters that are passed by reference.

*STRING – You use this option to specify that along with passing a pointer to a value, you may also use a string value. When you specify a string value in this situation, a temporary null-terminated variable is created and the pointer to this variable is used as the parameter. This option is useful in situations where you are calling APIs that use string pointers as parameters and you would rather pass a string value.

*RIGHTADJ – You use this option to automatically right adjust the value of a parameter defined with the VALUE or CONST keywords. If the subprocedure parameter is defined as a varying length, this option is not valid. However, you can use a varying length field as the value for the parameter.
Depending on your version of the operating system, some of these options may not yet be available. When determining when to use which value, be sure you understand how each one works and how it will affect your application

Posts : 442
Join date : 2009-07-24

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum