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



I understand your confusion over APIs/functions.

We tend to think of C library and other callable functions as APIs even if
they are not strictly documented as such.  API means Application Programming
Interface (or some variant of those words) so anything supplied by the
system that can be called is an API.

There are two type of call on the system
- program level calls - otherwise known as dynamic calls.
- procedure level calls - otherwise known as bound calls.

APIs such as QCMDEXC are in the former category.  Such calls can only return
information to the caller by modifying a parameter.  C-style function calls
such as sleep are bindable APIs and can return values.

Here's an example of sleep - _not_ tested and it is a long time since I
coded COBOL so ....

           PROCESS nomonoprc

       PROGRAM-ID.   SleepyTime.

       ENVIRONMENT DIVISION.

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       77 sleep-time           Pic 9(9) binary value 5.
       77 result               Pic S9(9) binary.

       PROCEDURE DIVISION.

       main-paragraph.

           DISPLAY "Going to sleep now"

           CALL PROCEDURE "sleep"
               USING   sleep-time
               GIVING  result.

           IF result = -1
               DISPLAY "Cannot get to sleep!"
               PERFORM error-routine
           END-IF.

           DISPLAY "Time to wake up!".

           STOP RUN.


       error-routine.
           DISPLAY "Rats - it didn't work - I wonder why?"


The "Process nomonoproc" is needed to ensure that "sleep" is the function we
use and not "SLEEP".

The "CALL PROCEDURE" defines this as a bound call - not a dynamic call.
There is a process option that you can use (LINKPRC I believe) that will
make PROCEDURE the default - if you use that then calls to a program would
be CALL PROGRAM.

In order to allow the binder to locate sleep you will need to specify
Binding Directory QC2LE to the CRTBNDCBL command.  QC2LE is the binding
directory supplied with the C compiler and may be used to locate most any of
the C-style APIs - including all of the Unix-style IFS APIs etc.

Note that if a C-type call fails you need to call __errno to find out why -
this involves defining based fields in Linkage and I'm afraid I don't have
time to dig up an example.

P.S. Please when you respond to messages in a digest _change_ the subject
back to something meaningful - it will help the next HP exile locate the
info they need in the archives.  talking of the archives, you will find some
of the info on C function calls there, and also in the COBOL forum at
www.iseriesnetwork.com


Jon Paris
Partner400

www.Partner400.com
www.RPGWorld.com



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.