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



I am not sure if I should post this here or in the Java list.  

I have done a little of calling Java methods from an RPG program, but not
enough to know the answer to my question.  Can RPG do a call back to a Java
method?  The calling Java program must first be able to pass in a "pointer"
to the method that should be used for the call back.  Then the RPG program
would make a call to that method, but would that be the same object in
memory or would it create a new one?  First off can Java pass a pointer of a
method to an RPG program, and second, can RPG accept and call a pointer to a
method vs. a procedure or class?

Thanks for any help that is given,
Aaron Bartell

-----Original Message-----
From: Bartell, Aaron L. (TC) [mailto:ALBartell@xxxxxxxxxxxxxx]
Sent: Thursday, February 20, 2003 12:35 PM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Call Back information


Thanks for the example Scott.

Through your example I am thinking that call backs are directly related to
procedure pointers and the dynamic routing of procedure calls(it seems that
way anyway), correct?  We build a lot of external service programs that are
then bound to calling programs and used as needed.  We are looking for ways
to utilize the call back concept to talk back and forth between sub
procedures in the service program and in the main calling program.  We have
looked at using them for error handling, returning data structures to fill
subfiles, and other uses that follow the same premise.  

Does anybody have opinions on when to use call backs and/or anything to
watch out for?

TIA,
Aaron Bartell 


-----Original Message-----
From: Scott Klement [mailto:klemscot@xxxxxxxxxxxx]
Sent: Thursday, February 20, 2003 11:22 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Call Back information



On Thu, 20 Feb 2003, Bartell, Aaron L. (TC) wrote:
>
> Could somebody point me to some documentation on how Call Backs work in
the
> ILE environment?  I found references to it in the IBM Redbooks when they
> talk about qsort and other C API's but they didn't really layout how it
all
> works under the covers.
>

I'm not really sure what type of answer you're looking for...   All it
does is call the procedure that you've passed as a parameter.

Here's sample code that demonstrates callbacks from both the APIs point
of view and your point of view...   it's really simple code, but maybe
will illustrate how they work:

     H DFTACTGRP(*NO)

     D DsplyNum        PR
     D    DspTxt                     50A   const
     D StatusNum       PR
     D    DspTxt                     50A   const
     D Counter         PR
     D    Callback                     *   value procptr

     c                   callp     Counter(%PADDR('DSPLYNUM'))
     c                   callp     Counter(%PADDR('STATUSNUM'))

     c                   eval      *inlr = *on
     c                   return


      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * This is a sample procedure to demonstate how you "call-back"
      * another procedure.
      *
      * All it does is count from 1-5, one count per second, and then
      * pass the text 'Count is XXXXXXXXXX' to the callback proc
      *
      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P Counter         B
     D Counter         PI
     D    Callback                     *   value procptr
     D my_callback     PR                  ExtProc(Callback)
     D   text                        50A   const
     D qcmdexc         PR                  ExtPgm('QCMDEXC')
     D   cmd                        200A   const
     D   length                      15P 5 const
     D x               s             10I 0
     c                   for       x = 1 to 5
     c                   callp     qcmdexc('DLYJOB DLY(1)': 200)
     c                   callp     my_callback('Count is ' + %editc(x:'X'))
     c                   endfor
     P                 E


      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * This is a callback proc that just DSPLY's the message passed
      * to it.
      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P DsplyNum        B
     D DsplyNum        PI
     D    DspTxt                     50A   const
     c     DspTxt        dsply
     P                 E


      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * This is a callback proc that displays the message passed to it
      * as a status message
      *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P StatusNum       B
     D StatusNum       PI
     D    MsgTxt                     50A   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                    1A

     D dsEC            DS
     D  dsECBytesP             1      4I 0 inz(0)

     D MsgKey          S              4A

     c                   callp     SndPgmMsg('CPF9897': 'QCPFMSG   *LIBL':
     c                               MsgTxt: %size(MsgTxt): '*STATUS':
     c                               '*EXT': 0: MsgKey: dsEC)

     P                 E

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.