|
Here's a brain dead example of a program that has a module bound to it. No /copy necessary unless you want to keep your prototypes in a copy member. Main program is AARI and bound module is AARI2. *************** Beginning of data ************************************************** 0001.00 Daari2 pr 8 0002.00 Dparm 8 value 0003.00 Dpassedvalue s 8 0004.00 Dchangedvalue s like(passedvalue) 0005.00 C eval passedvalue = 'original' 0006.00 C eval changedvalue = aari2(passedvalue) 0041.00 C SETON LR ****************** End of data ***************************************************** 0001.00 Hnomain 99 0002.00 Daari2 pr 8 99 0003.00 Dparm 8 value 99 0004.00 Paari2 b export 99 0005.00 Daari2 pi 8 99 0006.00 Dparm 8 value 99 0007.00 Dlocalvar s like(parm) 99 0008.00 C eval localvar = 'changed ' 99 0009.00 C return localvar 99 0010.00 Paari2 e 99 ****************** End of data *********************************************************************** AARI passes passedvalue by value to AARI2. AARI2 returns localvar. If you passed passedvalue by reference, the default, you could change its value in the procedure and if that was all you wanted the procedure to do, the procedure wouldn't have to return a value. Note the use of the export keyword in AARI2. This is necessary for the binding step described below. Notice that the procedure interface and procedure prototypes are almost identical. The procedure prototype lets the compiler know that your program will refer to a procedure as described in the prototype (name, return type, parameters and their data types. The procedure interface begins the actual definition of the procedure. After you have coded a few of these, it becomes second nature. Creating the program is a two step process. First do a crtrpgmod (option 15 in pdm) on both programs. Check the debug information parameter. You probably would prefer *list or *all over the default which doesn't allow source level debugging. Then do a crtpgm. Here's the command line from mine: CRTPGM PGM(JEFTST/AARI) MODULE(JEFTST/AARI JEFTST/AARI2) ACTGRP(*CALLER). The export keyword mentioned above allows the module to advertise its name as available to other programs that might need to use it. Hope I haven't muddied the waters too much. > -----Original Message----- > From: Ronald Nance [mailto:RNANCE@commerceinsurance.com] > Sent: Friday, July 30, 1999 9:08 AM > To: RPG400-L@midrange.com > Subject: prototyping > > > Hello People, > > I am in the process of evaluating RPGILE with a team of people (8) > and I have been having a diffacult time creating a subprocedure. Let > me lay out what I have and what I want to do leave the rest to you.. > > I have a program (pgma) that calls a program (pgmb). Pgmb receives > some parms, performs some calculations and returns several values. > Pgmb contains only calculation specs and definitions. > > So I believe this will make an ideal subprocedure. > > I am not sure if I have to use the /copy to bring pgmb into pgma > after I add the necessary prototype code and I am not sure how to set > up the parameters. The example in the programmers guide is not clear > enough for me or I am very dense. > > I have been using the ILE RPG/400 programmers guide and I am not > haveing any luck completing my task. So, a simple coding example > would help me tremendously. > > PGMA > code example > > PGMB > code example > > Ronald Nance > Commerce Insurance Group > Webster, MA. 01570 > (508) 943-9000 Ext: 4078 > > rnance@commerceinsurance.com > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to > RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +---END > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---END
As an Amazon Associate we earn from qualifying purchases.
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.