× 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.



Hi Cyndi,

You have a mismatch between your prototype (PR) and procedure interface (PI). One of them provides a return value, and the other does not -- this is the cause of the errors you cite.

I have written many routines named 'die' over the years. Since it's just a quick example of how to do a certain type of coding, I tend to write a different one for each different assignment. (More recently, I've been calling it 'ReportError' instead of 'die', but it's similar.) I make no guarantees that they'll all be the same.

Most likely, you have a different definition of 'die' in your library list somewhere. (Most likely in a copy book named ERRNO_H)



On 7/25/2012 8:29 AM, Cyndi Bradberry wrote:
If you get two copies, my apologies, cross posted to the RPG list also.

Scott's original code from the savf on his site. I have put it all back and I still get the error about needing a return

P die B
D die PI
D peMsg 256A const

D SndPgmMsg PR ExtPgm('QMHSNDPM')
D MessageID 7A Const
D QualMsgF 20A Const
D MsgData 256A Const
D MsgDtaLen 10I 0 Const
D MsgType 10A Const
D CallStkEnt 10A Const
D CallStkCnt 10I 0 Const
D MessageKey 4A
D ErrorCode 32766A options(*varsize)

D dsEC DS
D dsECBytesP 1 4I 0 INZ(256)
D dsECBytesA 5 8I 0 INZ(0)
D dsECMsgID 9 15
D dsECReserv 16 16
D dsECMsgDta 17 256

D wwMsgLen S 10I 0
D wwTheKey S 4A

c eval wwMsgLen = %len(%trimr(peMsg))
c if wwMsgLen<1
c return
c endif

c callp SndPgmMsg('CPF9897': 'QCPFMSG *LIBL':
c peMsg: wwMsgLen: '*ESCAPE':
c '*PGMBDY': 1: wwTheKey: dsEC)

c return
P E




This is from page 76 of 996 of the ILE RPG language reference for V7R1. From what it shows, I think I need the return after the PI section of parameters and then putting that parameter definition into the return statement. I have tried variations and what I am trying doesn't work.


Figure 5 shows a subprocedure, highlighting the different parts of it.

* Prototype for procedure FUNCTION
D FUNCTION PR 10I 0 1
D TERM1 5I 0 VALUE
D TERM2 5I 0 VALUE
D TERM3 5I 0 VALUE
P Function B 2
*-------------------------------------------------------------
* This procedure performs a function on the 3 numeric values
* passed to it as value parameters.
**
This illustrates how a procedure interface is specified for a
* procedure and how values are returned from a procedure.
*-------------------------------------------------------------
D Function PI 10I 0 3
D Term1 5I 0 VALUE
D Term2 5I 0 VALUE
D Term3 5I 0 VALUE
D Result S 10I 0 4
/free
Result = Term1 ** 2 * 17
+ Term2 * 7 5
+ Term3;
return Result * 45 + 23;
/end-free
P E 6



1 A Prototype which specifies the name, return value if any, and parameters
if any. Since the procedure is not exported from this module, it is optional
to specify the prototype.
2 A Begin-Procedure specification (B in position 24 of a procedure
specification)
3 A Procedure-Interface definition, which specifies the return value and
parameters, if any. The procedure interface must match the corresponding
prototype. The procedure-interface definition is optional if the
subprocedure does not return a value and does not have any parameters
that are passed to it. If the prototype had not been specified, the
procedure-interface definition would be used by the compiler to implicitly
define the prototype.
4 Other definition specifications of variables, constants and prototypes
needed by the subprocedure. These definitions are local definitions.
5 Any calculation specifications, standard or free-form, needed to perform
the task of the procedure. The calculations may refer to both local and
global definitions. Any subroutines included within the subprocedure are
local. They cannot be used outside of the subprocedure. If the
subprocedure returns a value, then the subprocedure must contain a
RETURN operation.
6 An End-Procedure specification (E in position 24 of a procedure
specification)




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.