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.

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.

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.

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

Following

Share this item with your network: