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



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

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.
QGPL/MYPGM).

If first parameter is an integer you can dereference the pointer by
doing:
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
anything.

Hope this helps.

Elvis


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

Hello,
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
client.  

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,
Glen


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,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.