|
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
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.