Calling CL program fron a C/400 program?

45 pts.
Tags:
Application development
AS/400
CLP
Web development
Dear, I'm very new in C/400 developement and I'm facing an issue. I've some CL program that I would like to call in my C/400 program... Well, ok, I can use the function "error=system(...)"... but my CL program as to return me some information. Here is my CL prgram: PGM PARM(&queue &queue_lib &sens) DCL &queue *CHAR 10 DCL &queue_lib *CHAR 10 DCL &sens *CHAR 1 CHGVAR &sens '1' /* not there ? */ CHKOBJ &queue_lib/&queue OBJTYPE(*DTAQ) MONMSG MSGID(CPF9801) EXEC(GOTO CMDLBL(CHKEND)) CHGVAR &sens '0' /* fine, it is there */ CHKEND: RETURN ENDPGM How can I call this program in a C/400 program and be able to know the value of the sens parameter? Thanks in advance for your help. Best regards,

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi Pierre,
This is quite simple if you know the name of the program at compile time.
All you have to do in your C code is:
1. Add the #pragma clause:
#pragma linkage (progname, OS)
void progname(char *queue, char *queuelib, char *sens);
2. Just call the program like you call any other C function:
progname (queue, queuelib, sens);
When the call ends, the “sens” variable will contain the return value from the CL program.

This works for calling CL program, RPG program or any other program object.

If you do not know the name of the program at compile time, that is the C program have to call a “variable” program name, this is more complicated.
In such case, you have to resolve the pointer to the program object and use the pointer as a function placeholder.

Hope this helps.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • JDWWms
    Lots of easier choices if you don't know C. Use a DATAQ and just have a porgram on the remote system monitoring for program calls. You can send the command string you want run and the remote program can use EXCCMD to process the string. Or use FTP to connect and do just about anything you want.
    0 pointsBadges:
    report
  • TomLiotta
    Lots of easier choices if you don’t know C. Use a DATAQ... Since coding the call to the QSNDDTAQ API will be at least as difficult as coding the call to the CL program, and it will also require coding for QRCVDTAQ to get returned data, I'm not clear at all how it would be easier. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following