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



Hi Igor,
 
<snip>
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???
</snip>
 
You should treat your variables in the same way you treat them in java -
make the variables private, but create getter and (possibly) setter
sub-procedures that are exported.
 
In the getter sub-proc you simply return the variable.
 
So, in moduleB, if you want to retrieve var3 from moduleA you would use:
 
moduleBVar3 = getModuleAVar3();
 
If you want moduleB to set variable var3 in moduleA then you would use:
 
setModuleAVar3(moduleBVar3);
 
So, the only thing you need to do to make your variables accessible to other
modules is to create getter sub-procs and export them.
 
Now, if you want to mimic a full-blown o-RPG approach then you can place
MOST of the moduleA global variables into a DS. You then set this as an
array (32767 elements) and base it on a pointer.
 
Then, in initialize() you would allocate memory to the pointer, increment an
element counter, set all of the global variables in the current element, and
return the element number. Then, on every procedure that calls moduleA, the
first parm would be the element number - this is the "instance". This allows
moduleA to dynamically create "internal" instances of itself. You can then
work with several "instances" of moduleA. This approach is not novel.
Whenever you interface with java you have to pass the object as the first
parm. I just don't ever see it used in a pure RPG environment. It can be
very handy when parsing data recursively.
 
In this scenario, initialize() would be considered a STATIC sub-proc: To do
this, the element counter would be need to be kept out of the array - as
there is only one "instance" of this global variable it is considered a
STATIC variable. So, to make a static sub-proc, simply exclude the global
variables it uses from the global DS array.
 
This is probably more than you need (or care) to know, but I add it to
emphasise that you can do MANY things with RPG sub-procs. Some of which may
surprise you.
 
Cheers
 
Larry Ducie

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.