Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Call a variable Program in C

41 views
Skip to first unread message

T.Withana

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
How can you call a variable Program name in C.
To have the Program Name in a variable and call it (like in RPG)

Any help will be appreciated

Tissa

Erik Elmgren

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to

"T.Withana" wrote:
>
> How can you call a variable Program name in C.
> To have the Program Name in a variable and call it (like in RPG)

You can use the system() function, section 1.2.204 of "C/C++ Run-Time
Library Reference" SC09-2715-00 describes this function.

Regards, Erik

Karl Hanson

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to

Clarification: the system() function will execute a CL command, so to
call a program you would pass it a command string such as "CALL
PGM(mylib/mypgm)". Also, if you need better error information when the
called program terminates abnormally, the QCMDEXC (Execute Command) or
QCAPCMD (Process Command) APIs can be used instead of system(). The
APIs let you monitor for exceptions caused/signalled by the called
program, or in the case of QCAPCCMD to check the Error Code parameter
after the called program returns. See the Program and CL Command APIs
section of the System API Reference manuual:
http://publib.boulder.ibm.com:80/cgi-bin/bookmgr/DOCNUM/SC41-5801-02

--

Karl Hanson

Patrick Townsend

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to T.Withana

You can include the header file QCMDEXC.h and use this API. It takes two
parameters: a command string to execute and a length. You can find the C
header file in your QSYSINC library.

Patrick

"T.Withana" wrote:
>
> How can you call a variable Program name in C.
> To have the Program Name in a variable and call it (like in RPG)
>

> Any help will be appreciated
>
> Tissa

--
IBM AS/400 communications, FTP automation, and network security
software and consulting services.

http://www.patownsend.com


Derek Butland

unread,
Feb 13, 1999, 3:00:00 AM2/13/99
to
Tissa,

Assuming you are trying to do something like this:

*-------------------------------------------------------------------
D Message S 20A INZ('Hello')

C *ENTRY PLIST
C PARM MyPgm 10

C CALL MyPgm
C PARM Message
C
C RETURN
*-------------------------------------------------------------------

...a rough equivilent in C would be:

/*-------------------------------------------------------------------*/
#include <miptrnam.h>

typedef char Char20 [ 20];

typedef void (MyPgmType) ( Char20 * );
#pragma linkage(MyPgmType,OS)


main(int argc, char *argv[])
{
MyPgmType *MyPgmPtr;
Char20 Message = "Hello";

MyPgmPtr = rslvsp( _Program, argv[1], "*LIBL", _AUTH_OBJ_MGMT );

MyPgmPtr( &Message ); /* Call the program */

return;
}
/*-------------------------------------------------------------------*/

hth,
Derek


T.Withana wrote in message <7a035i$ihk$1...@reader1.reader.news.ozemail.net>...

0 new messages