|
I have some idea of creating RPG modul that will simulate something what
is in object oriented programing known as an Interface object. The MODUL
should implement parser for specific kind of markup language files
(similar to SAX parser).
The idea is next:
Modul A has subProcedures initalize() - Exported, startProcess() -
Exported and its global variables var1,var2...varN that are known at
compile time and handleEvent(), errorRecover() that are referencing on
some procPtrs which should be defined when subprocedure initalize() is
called (run time). Code should look like this:
*------------------------------------MODUL A ________START
D initalize PR
D proc1Pointer * ProcPtr VALUE
D proc2Pointer * ProcPtr VALUE
D startProcess PR
D Var1
D Var2
D Var3
....
D VarN
D handleEvent PR ExtProc(PointerToMe1)
D errorRecover PR ExtProc(PointerToMe2)
.....
P initalize B Exported
D initalize PI
D proc1Pointer * ProcPtr VALUE
D proc2Pointer * ProcPtr VALUE
/free
PointerToMe1=proc1Pointer;
PointerToMe2=proc2Pointer
return;
/end-free
P initalize E
P startProcess B Exported
//do something....
dow
if exception;
//call procedure but what will
//it do will be known at run time
errorRecover();
EndIf;
If dataReady;
//call procedure but what will
//it do with data will be known at run time
handleEvent();
EndIf;
EndDo
P startProcess E
*---------------------------------------MODUL A_____________END
Modul B has subProcedures mainSubp(), supp1(), subp2() and two special
subp myEventHandler(), myErrorHandler() whose proc pointers should be
passed to modulA:
*----------------------------------------MODUL B_____________START
D mainSubP PR
D subp1 PR
D subp2 PR
D myEventHandler PR
D myErrorHandler PR
....
P mainSubP B
/free
//initalize MODUL A
initalize(%PAddr('myEventHandler'):%PAddr('myErrorHandler'));
//prepare MODUL B
subp1();
subp2();
//start procession in MODUL A
startProcess();
/end-free
P mainSubP E
....
P myEventHandler B
//here is implementation which will depend on END programers idea
P myEventHandler E
P myErrorHandler B
//here is error recovery
P myErrorHandler E
*----------------------------------------MODUL B_____________END
The Sourcers guide to RPG has just one trivial example with procedure
pointers which couldn't give me all the answers.
Here is list of questions so if you know help me:
1. What is SCOPE of myEventHandler and myErrorHandler??? I mean, can I
manipulate with Var1, Var2 ... VarN from MODUL A if subp implementation is
in ModulB
2. If I can't acess VAR1, VAR2... VarN has anyone any IDEA how to make
them accessible??? EXPORT them (how can I do that???) or to define
USERSPACE that will hold neaded data and would be visible in MODULE B and
MODUL A???
3. If I want to write to PF named logPF in myEventHandler where should I
define that file in MODUL A or MODUL B??? (My Idea is that file is defined
in MODUL B so the interface could be more flexible)
4. Is there any literature/link/book/pdf which describes procedure
pointers more detailed than Sourcers guide???
Thank you all!
Igor Bešlić, dipl. ing. rač.
VOLKSBANK d.d.
OJ Informatika
Zelinska 2, 10000 Zagreb
tel: +385 1 6326422
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.