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



Bob,

Coding isn't the problem.

The issue Mark is trying to solve is ensuring that a procedure passed by
pointer has the interface expected.
Right now, it's left to the developer to ensure this. If you screw it up
and your lucky, the code will crash. If you're not lucky you can have all
kinds of funny runtime issues caused by parameter mismatches.

Mark, I agree this would be nice to have....it would be some nice insurance
to have when using procedure pointers

Charles

On Wed, Mar 25, 2015 at 9:35 AM, Roche, Bob <broche@xxxxxxxxxxxxxxxxx>
wrote:

Save it as a snippet?

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Mark
Murphy/STAR BASE Consulting Inc.
Sent: Wednesday, March 25, 2015 8:30 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: New Template Type

You know what would be useful? A prototype template, let me explain.

I created a procedure that takes as a parameter a pointer to a callback
procedure. The module with the caller (procA) and the callback (procB)
procedures doesn't really need a prototype for procB as it isn't really
called in a traditional way. But, the called procdedure (procC) which
receives a pointer to procB and executes it, does need a prototype that
references the procedure pointer. Now that prototype in procC has to be
local because it references the procedure pointer being passed in as a
parameter, but even if I found a way to make the pointer and prototype
global, I couldn't use the same prototype for procB because it references
the pointer, and I really don't necessarily always want to use the same
name for procB. It is a callback after all, and I might have more than one
procedure in a given program providing services to procC. A prototype
template would allow me to define the prototype in procC
LikeProc(callback_t) with a reverence to the local procedure pointer be

ing passed in as a parameter, and also define the callback procB
LikeProc(callback_t) which would provide the matching procedure interface
without the procedure pointer, but the parameters and return would be the
same. Here is what I would like to see.

dcl-pr callback_t Int(10) Template;
Parm1 <keywords>;
Parm2 <keywords>;
end-pr;


dcl-proc procA;

...
procC(%paddr(procB));
...
end-proc;

dcl-proc procB LikeProc(callback_t);

<procedure body>
end-proc;

dcl-proc procC;
dcl-pi *n;
callbackPtr Pointer(*Proc);
end-pi;

dcl-pr callback LikeProc(callback_t) ExtProc(callbackPtr);

callback(...: ...);
...
end-proc;

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
--
This is the RPG programming on the IBM i (AS/400 and 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 IBM i (AS/400 and 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:
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.