Not sure if I understood your question completely, but here it goes

You can define a C program to take arbitrary number of parameters by
declaring it as:
void main(int argc, char * argv[])

argc would tell you how many arguments (parameters) were passed in and
argv is an array holding pointers to those parameters, with argv[0]
containing a special value, qualified name of the program itself (i.e.

If first parameter is an integer you can dereference the pointer by
int firstParm = *(int *)argv[1];

What this does is cast default character pointer to a integer pointer,
dereferences the address and finally assigns the value to the local
variable firstParm.

If the input is a character string there is no need to dereference

Hope this helps.


-----Original Message-----
From: c400-l-bounces@xxxxxxxxxxxx [mailto:c400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Glen Marchesani
Sent: Tuesday, June 10, 2003 7:22 PM
To: c400-l@xxxxxxxxxxxx
Subject: [C400-L] calling a program using a variable

I am looking for a C/MI api that lets me call a program
(library and program name are variable) with a variable set
of parameters.

I have a client server app where the server is an AS400 ILE
C program.  The program allows a remote program call.  The
client passes the library and program to call with the
paremeter types (input, output, both), length and data if
it is (input or both).  It then calls the program passing
the parameters and allocating the appropriate memory for
each parm.  When the call is complete it takes the
parameters and passes the output and both parms back to the

I am currently calling an RPG program to do the actual
call.  Here is the code 

c                   call(e)   program                   
c                   parm                    parm01      
c                   parm                    parm02      
c                   parm                    parm03      
c                   parm                    parm98      
c                   parm                    parm99      

where parm01..parm99 are based on pointers.  It is *UGLY
but it works.  Well not completely.  It doesn't work for
CLP because the init of CLP sees 100 parms being passed and
some IBM api's also have this feature (for lack of a better
word).  Which means for each CLP and IBM api I wrap the
call in an RPG program that calls the CLP/IBM api with the
correct parms.

look forward to hearing everyone's cleverness,

with a smile,

PS I know that there are as400 servers that could do this
for me but for architectural reasons they are not an option
as this server needs to be easily proxied and work inside
an already existing tcp tunneling architecture.

This is the C programming iSeries / AS400 (C400-L) mailing list
To post a message email: C400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by 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].