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



Back again... I tried out both Elvis' and Barbara's (I hope a first name
basis is ok!) solutions but I can't even get a compile:

"A parameter of type "main_args_t *" cannot be initialized with an
expression of type "char **"."

After taking a closer look at the language ref manual it seems as though one
*has* to pass char **? Just seems so incredibly awkward that I, just to
perform a simple SBMJOB on the call to this program, would need to go
through a CL program and manually append null terminators etc... (which is
what they do in the Programmer's guide when calling C from CL).


2009/2/24 Barbara Morris <bmorris@xxxxxxxxxx>

Olsson Erik wrote:
I want to submit a call to a program in batch, and the program needs to
take
a number of parameters.
If this was an interactive application I'd create the called program as a
service program, have a prototyped interface for controlling parameters
and
all would be fine.

Any better solutions than having the program called via SBMJOB to have a
main function and then manually typecast the parms from argv's char * to
their proper ones (say integers)?


If the parameters aren't all the same type, the argv parameter doesn't
have to be coded as an array. It can be coded as a pointer to a struct
with pointer subfields of the required type. (Don't forget the
"program-name" subfield for argv[0].)

typedef struct
{
char *pgmname;
char *userid;
char *code;
int *custno;
} main_args_t;

main (int argc, main_args_t *main_args)
{
char *userid = main_args->userid;
char code = *main_args->code;
int custno = *main_args->custno;

}

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

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.