×
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 07/04/2010, at 7:32 PM, David FOXWELL wrote:
Can Program1 call Program2 with a procedure pointer as a parameter
to tell program2 which subprocedure of program2 to call?
Simple answer is yes (and I see later appends give you information on
how to do that) but ...
I think this is impossible as Program1 needs to get the procedure
address of the subprocedures in program2. But, I am often wrong.
... this is where it gets weird. Normally this sort of behaviour is
used for a call-back routine. That is Program1 calls Program2 passing
a procedure pointer to a routine in Program1. Program2 then uses that
procedure pointer at some point in generic processing by "calling-
back" to Program1 to perform some operation that is specific to
Program1's requirements. It means Program2 can provide a generic
function that can be made more specific by the calling program.
Classic example is a sort function. The process of sorting is generic
but the actual data comparison is specific thus sort procedures often
take a procedure (or function) pointer to a specific comparison routine.
In your case you're doing the reverse; you want Program1 to invoke a
procedure in Program2 via a procedure pointer--almost as a direct call
into Program2. That means Program1 needs to know stuff about Program2
(otherwise known as tight-coupling). That would normally be better
served by a function-code parameter which Program1 uses to request
Program2 to perform a specific type of processing. This does result in
Program2 having a (possibly big) select statement that tests the
function-code and branches to the correct procedure but the resulting
interface is a lot cleaner than what you're proposing.
If you REALLY need Program1 to choose the procedures in Program2 then
Program2 should be a service program (with defined public interface)
and then you can just use normal ILE binding although you could also
use procedure pointers if required.
Seems to me you are trying to solve the wrong problem and as a result
making things far more complicated than they need be.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.