× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 22 Jun 2013 09:50, Booth Martin wrote:
<<SNIP>> I am only really interested in the values being returned.
<<SNIP>>

Others already responded with the changes required for resolution, both with parameters and an example using an actual /return value/ instead. Hopefully the following will help to further clarify, based on my presumption of the origin for the apparent confusion...

The parameters are passed by address and are capable of both input and output [e.g. referred to as an "INOUT" parameter in SQL], such that upon /return/ from the called-program, a new\changed value for the variable that was passed as a parameter, will be visible to the caller. These values are not /being returned/ as effected by a RETURN statement [the RETURN operation code]. The values are instead, merely _assigned_ in the called program [i.e. the resolution, as described in some other replies].

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508997.htm#idx3288
http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508997.htm#zzretrn
IBM i 7.1 Information Center -> Programming -> Programming languages -> RPG -> ILE RPG Language Reference -> Operations, Expressions, and Functions -> Chapter 22. Operation Codes
_i RETURN (Return to Caller) i_
"...
The RETURN operation causes a return to the caller. If a value is returned to the caller, the return value is specified in the expression operand.

The actions which occur as a result of the RETURN operation differ depending on whether the operation is in a cycle-main procedure or subprocedure. ...
..."

Unfortunately the example code snippets for "RetFld" and "RetArr", presented later in the above doc reference, show three different but consecutively coded RETURN requests. However only one RETURN operation would be coded in an actual source, because any RETURN operation that was coded beyond the first of multiple consecutive unconditional RETURN operations, would never execute; i.e. the first would effect a "return to the caller".

In conjunction with the example provided by Paul, the following documentation hopefully clarifies the distinction of the use and meaning of a /return value/ as contrasted with the use of a parameter as an input\output-capable means of obtaining a new\changed value from the invoked program\procedure.

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc09250869.htm#idx116
IBM i 7.1 Information Center -> Programming -> Programming languages -> RPG -> ILE RPG Language Reference -> RPG IV Concepts -> Chapter 3. Procedures and the Program Logic Cycle -> Subprocedure Definition
_i Return Values i_
"A procedure that returns a value is essentially a user-defined function, similar to a built-in function. To define a return value for a subprocedure, you must

1. Define the return value on both the prototype and procedure-interface definitions of the subprocedure.
2. Code a RETURN operation with an expression in the extended-factor 2 field that contains the value to be returned.

You define the length and the type of the return value on the procedure-interface specification (the definition specification with PI in positions 24-25). ...
..."


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.