× 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 10/5/2016 3:15 PM, Barbara Morris wrote:
...
You could use a C module for your main procedure. A C main gets its
parameters as an array of pointers. You could use this C module as the
program-entry module for any program where you want the parameters as an
array. You just have to name the RPG procedure RPGMAIN (or whatever name
you use in the C module).
...
// RPG "main"
ctl-opt nomain;

dcl-proc RPGMAIN export;
dcl-pi *n;
argCount int(10) value;
argArr pointer dim(400) options(*varsize);
end-pi;
dcl-s i int(10);

for i = 1 to argCount;
if argArr(i) <> *null;
// do something
endif;
endfor;
end-proc;


I forgot to mention that you could also define a data structure with a named pointer for each parameter, and base a variable of the required type on each pointer. Then copy the passed pointers to that data structure and process the pointers by name.

...
dcl-pi *n;
argCount int(10) value;
argDs likeds(argPointers);
end-pi;

dcl-ds argPointers qualified template;
ptr pointer dim(255);
end-ds;

dcl-s aPointer pointer template;

dcl-ds parms qualified inz;
pName pointer;
pType pointer;
pWhatever pointer;
end-ds;

dcl-s name char(10) based(parms.pName);
dcl-s type int(10) based(parms.pType);
dcl-ds whatever qualified based(parms.pWhatever);
something int(5);
someList char(1);
...
end-ds;

// copy the parameter array to the local pointers
parms = %subst(argDs : 1 : argCount * %size(aPointer));

// process the pointers
if parms.pName <> *null;
// process name
endif;
...


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.