Follow

Elastic COBOL Library Functions

The following CBL_* library functions commonly found in other compiler's runtime support are supported by Elastic COBOL

 

Function Parameters Return

Description

CBL_ALLOC_MEM

MEM-POINTER,
MEM-SIZE

0 OK,
1 invalid parameters

Dynamically allocate memory of MEM-SIZE bytes and set the COBOL pointer variable MEM-POINTER to the allocated.

CBL_AND

SOURCE,
TARGET

void

Perform a bit-wise AND operation between two arguments, updating the second with the result.

CBL_CHANGE_DIR

PATH

0 OK,
-1 invalid

Change the current working directory for the duration of this program to the given PATH (PIC X(n)).

CBL_CHECK_FILE_EXIST

PATH,
STATS

01 stats.
 03 file-size pic x(8) comp-x.
 03 file-date.
   05 day pic x comp-x.
   05 month pic x comp-x.
   05 year pic x(2) comp-x.
 03 file-time.
   05 hours pic x comp-x.
   05 minutes pic x comp-x.
   05 seconds pic x comp-x.
   05 hundredths pic x comp-x.

Check whether a file path exists and, if so, set the STATS parameter with statistics about it.

CBL_CLOSE_FILE

HANDLE, OPER

0 OK,
1 Failed

Close a byte stream (if OPER is 1) that was previously opened with CBL_OPEN_FILE (which returned a HANDLE).

CBL_COPY_FILE

SOURCE, DEST

0 OK,
1 Failed

Copy a file given by the path SOURCE to a new file given by DEST.

CBL_CREATE_DIR

PATH

0 OK,
1 Failed

Create any and all directories in the given PATH.

CBL_CREATE_FILE

PATH,
"r"|"w"|"rw"

0 OK,
1 Failed

Create a file with the given PATH and make it "r" (readable), "w" (writable) or "rw" (both).

CBL_DELETE_DIR

PATH 

0 OK,
1 Failed

Remove the directory, which must be empty, given by PATH.

CBL_DELETE_FILE

PATH

0 OK,
1 Failed

Remove the file given by PATH.

CBL_EQ

SOURCE,
TARGET,
LENGTH

void

Compare each byte in SOURCE and TARGET variables up to size LENGTH, storing a 0 (unequal) or 1 (equal) in each TARGET byte after comparison.

CBL_ERROR_PROC

OPER,
PROCNAME

0 OK,
1 Failed

Install (if OPER is 1) or de-install (if OPER is 0) a COBOL program name PROCNAME as a routine to be called upon error.

CBL_EXIT_PROC

OPER,
PROCNAME

0 OK,
1 Failed

Install (if OPER is 0) or de-install (if OPER is 1 or 3) a COBOL program name PROCNAME as a routine to be called upon program exit.

CBL_FLUSH_FILE

HANDLE 

0 OK,
1 Failed

Flush an (output) byte stream that was previously opened with CBL_OPEN_FILE (which returned a HANDLE).

CBL_FREE_MEM

POINTER

0 OK,
1 Failed

Free memory allocated through CBL_FREE_MEM. POINTER argument is set to the null pointer.

CBL_GET_OS_INFO

PARAM-BLOCK

01 param-block.
 03 os-length pic x(2) comp-x value 28.
 03 os-type pic x comp-x.
 03 os-version pic x(4) comp-x.
  05 os-sub2 pic x comp-x.
  05 os-sub1 pic x comp-x.
  05 os-minor pic x comp-x.
  05 os-major pic x comp-x.
 03 os-dbcs-support pic x comp-x.
 03 os-char-coding pic x comp-x.
 03 os-country-id pic x(2) comp-x.
 03 os-code-page pic x(2) comp-x.
 03 os-process-type pic x comp-x.
 03 os-rts-capabilities pic x(4) comp-x.
 03 os-product pic x(2) comp-x.
 03 os-product-major pic x(2) comp-x.
 03 os-product-minor pic x(2) comp-x.
 03 os-product-sub pic x(2) comp-x.
 03 os-fixpack pic x(2) comp-x.

0 OK,
1 Failed

Return various information about the operating system environment in which this program is running.

CBL_GET_PROGRAM_INFO FUNCTION,
PARAM-BLOCK,
BUF,
BUF-LEN

01 param-block.
 03 cblte-gpi-size pic x(4) comp-5.
 03 cblte-gpi-flags pic x(4) comp-5.
 03 cblte-gpi-handle usage pointer.
 03 cblte-gpi-prog-id usage pointer.
 03 cblte-gpi-attrs pic x(4) comp-5.

0 OK,
1 Failed

Return information about a function given by FUNCTION COMP-X value (0) the current function, (1) the named function in a PIC X(n) after the  the COMP-X value, (2) the calling program. Given information is returned in the PARAM-BLOCK and the function name queried is returned in BUF of length BUF-LEN

 CBL_IMP SOURCE,
TARGET,
LENGTH

 

0 OK,
1 Failed

Carries out a bitwise "logical implies" operation between two arguments of length LENGTH, storing the result of the IMP in each byte of TARGET.

CBL_JOIN_FILENAME

SPLIT-JOIN-PARAM,
JOIN-BUF,
PATH-BUF,
BASENAME-BUF,
EXT-BUF

0 OK,
1 Failed
 

Forms a filename by joining together its component parts; that is, the pathname, basename and extension. Operation is under control of an extraordinarily complex structure SPLIT-JOIN_PARAM.

CBL_LOCATE_FILE

USER-FILE-SPEC,
USER-MODE,
ACT-FILE-SPEC,
EXIST-FLAG,
PATH-FLAG

01 actual-file-spec
  03 buffer-len pic x(2) comp-x.
  03 buffer pic x(n).

0 OK,
1 Failed 

 Find a file based on certain criteria

CBL_NOT

TARGET,
LENGTH

void

Perform a bit-wise NOT operation on the TARGET bytes of given LENGTH of the TARGET parameter, updating the parameter TARGET.

CBL_OPEN_FILE

PATH,
ACCESS,
DENY,
BLOCKSIZE

HANDLE

Open the file given by PATH as readable (ACCESS="r"), writable (ACCESS="w") or both (ACCESS="rw"), ignoring DENY and setting the fixed block size to BLOCKSIZE if non-0.  Return a HANDLE used in other CBL_*_FILE operations.

CBL_OR

SOURCE,
TARGET,
LENGTH

 

Perform a bitwise "OR" operation on the first two arguments of length LENGTH, updating the TARGET bytes with the result of each operation.

CBL_READ_DIR

PATH,
LENGTH

 

Set the PATH parameter to the name of the current user's directory (Java USER.DIR property) and its LENGTH

CBL_READ_FILE

HANDLE,
OFFSET,
LENGTH,
FLAGS,
BUF

 

Read the file with the handle previously returned with the CBL_FILE_OPEN library call, beginning at OFFSET position within the file, a sequence of bytes of length LENGTH, the result of which is stored in BUF.  FLAGS=128 indicates to return the length of the file in LENGTH.

CBL_RENAME_FILE

SOURCE,
TARGET

0 OK,
1 Failed

Rename a file name SOURCE as new name TARGET

CBL_TRANSFORM

INPUT,

ERR,

["CONV(EBC2ASC|ASC2EBC)"],

["FROMCHAR(inputcharset)")],

["TOCHAR(outputcharset)"],

["XFDXML(/path/toxfdxml)"]

INPUT - COBOL field,

ERR - COBOL field PIC X(256)

Return values :-            0 OK,

1 Exception

2 Error

Transform the input field data from either EBCDIC to ASCII or vice versa. The default transformation is from EBCDIC to ASCII . The default input charset is IBM1047 and the default output charset is ISO-8859-1. When data types varies in the transform field due to REDEFINES usage, use the XFDXML param to specify the path to the XFDXml file

CBL_TOLOWER

TARGET,
LENGTH

0 OK,
1 Failed

Translate the parameter character values to lower case characters, return the changed buffer in TARGET.

CBL_TOUPPER

TARGET,
LENGTH

0 OK,
1 Failed

Translate the parameter character values to upper case characters, return the changed buffer in TARGET.

CBL_WRITE_FILE

HANDLE,
OFFSET,
LENGTH,
FLAGS,
BUF

0 OK,
1 Failed

Write a record in the file with the handle previously returned with the CBL_FILE_OPEN library call, beginning at OFFSET position within the file, a sequence of bytes of length LENGTH, from the data located in BUF.  FLAGS are ignored.

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk