This is just a curiosity poll on my part. I'm wondering if anyone out there
has ever really used any C standard library routines (versus user written
code) in a COBOL program. I know that many may wonder "Why? What do I get
out of it." IMO, there are some useful routines in the standard C library
which could be used in COBOL.

One in particular which shows up quickly is the C language "cuserid()"
function. It will return the RACF id under which the program is running.
Now, since cuserid() plops a LOW-VALUE as an end-of-string delimiter, that
needs to be taken into consideration. Something like the following worked
for me:

01 USERID-PLUS-1
     05   USERID PIC X(8).
     05   FILLER   PIC X.
01 CUSERID-POINTER POINTER.

CALL 'CUSERID' USING USERID-PLUS-1.

as did

CALL 'CUSERID' USING USERID-PLUS-1
          RETURNING CUSERID-POINTER.

But this latter is unnecessary since the ID will be in USERID. But it might
have a LOW-VALUE, so it is better to do a MOVE SPACES TO USERID before the
CALL and a INSPECT USERID REPLACING LOW-VALUES BY SPACES after the call.

There are a lot more "interesting" C library functions which might be
useful. Such as the regular expression library for advanced text scanning
(OK, not a big COBOL thing). How about __get_cpuid() to get the CPU id of
the processor you're running on? DES encryption of data? The sprintf()
function to create a nicely formatted human readable message easily (not a
lot of space padding) although STRING might do this as well. On older
compilers, use the "calloc()" and "malloc()" function to get dynamic
storage areas to map with the LINKAGE SECTION. How about using "popen()" to
fire up a UNIX process to do some work for you?

Well, I'm going nutso again.

-- 
"Irrigation of the land with seawater desalinated by fusion power is
ancient. It's called 'rain'." -- Michael McClary, in alt.fusion

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to