calling a C function in COBOL ILE

195 pts.
Tags:
AS/400
COBOL
ILE for iSeries
RPGLE
In RPGLE I can call a C function like this: D sin PR extproc('sin') D parm F value C Eval mySine = sin( deg ) How do I do this in COBOL? Any examples? Thank you.
ASKED: January 2, 2008  6:15 PM
UPDATED: January 3, 2008  2:40 AM

Answer Wiki

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

If you had a sample RPG program such as:

<pre>
h dftactgrp(*no) bnddir(‘QC2LE’)

dsin pr 8f extproc(‘sin’)
d Parm 8f value

dMySine s 8f

/free
MySine = sin(1.570796326750000E+000);
dsply MySine;
*inlr = *on;
return;
/end-free
</pre>

and wanted the equivalent in COBOL, then:

<pre>
PROCESS NOMONOPRC.
IDENTIFICATION DIVISION.
PROGRAM-ID. SIN.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 Parm COMP-2 VALUE 1.570796326750000E+000.
01 MySine COMP-2.

PROCEDURE DIVISION.
BEGIN.
CALL PROCEDURE ‘sin’ USING BY VALUE Parm
GIVING MySine.
DISPLAY MySine.
EXIT PROGRAM.
</pre>

and CRTBNDCBL PGM(SIN) BNDDIR(QC2LE) should get you going.

Alternatively you could also:
<pre>
CALL PROCEDURE ‘sin’ USING BY VALUE 1.570796326750000E+000
GIVING MySine.
DISPLAY MySine.
</pre>

Bruce

Discuss This Question:  

 
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

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