🛠️ P3/COBOL 25.1.0-SNAPSHOT is available for preview.
User Guide
Subroutines
CBL_

Bytestream IO Subroutines

These subroutines mimic some of the functionality corresponding the Micro Focus1 COBOL library routines.

CBL_CHECK_FILE_EXIST

USING filename, cbl-file-exist-detail [RETURNING status-return]

Where:

01  filename                    pic x(...).
01  cbl-file-exist-detail.
    03 fe-filesize              pic x(8) comp-x.
    03 fe-date.
        05 fe-day               pic x comp-x.
        05 fe-month             pic x comp-x.
        05 fe-year              pic x(2) comp-x.
    03 fe-time.
        05 fe-hours             pic x comp-x.
        05 fe-minutes           pic x comp-x.
        05 fe-seconds           pic x comp-x.
        05 fe-hundreths         pic x comp-x.
01  status-return               pic s9(5).

CBL_OPEN_FILE

USING filename, access-mode, deny-mode, device, file-handle [RETURNING status-return]

Where:

01  filename                        pic x(...).
01  access-mode                     pic 9.
01  deny-mode                       pic 9.
*>01  device (not used )
01  file-handle                     pic x(4).
01  status-return                   pic s9(5).
    88 is-ok                        value 0.
    88 is-arg-error                 value 9997.
    88 is-wrong-no-args             value 9998.
    88 is-not-readable              value 9990.
    88 is-not-writable              value 9991.
    88 is-not-readwriteable         value 9992.
    88 is-unknown-access-mode       value 9993.
    88 could-not-lock-exclusively   value 9995.
    88 file-does-not-exist          value 9994.
    88 unexpected-exception         value 9999.

CBL_CREATE_FILE

USING filename, access-mode, deny-mode, device, file-handle [RETURNING status-return]

Where:

01  filename                        pic x(...).
01  access-mode                     pic 9.
01  deny-mode                       pic 9.
*>01  device (not used )
01  file-handle                     pic x(4).
01  status-return                   pic s9(5).
    88 is-ok                        value 0.
    88 is-arg-error                 value 9997.
    88 is-wrong-no-args             value 9998.
    88 could-not-lock-exclusively   value 9995.
    88 file-already-exists          value 9996.
    88 unexpected-exception         value 9999.

CBL_CLOSE_FILE

USING file-handle [RETURNING status-return]

Where:

01  file-handle                 pic x(4).
01  status-return               pic s9(5).
    88 is-ok                    value 0.
    88 is-arg-error             value 9997.
    88 is-wrong-no-args         value 9998.
    88 handle-not-found         value 9989.
    88 unexpected-exception     value 9999.

CBL_DELETE_FILE

USING filename [RETURNING status-return]

Where:

01  filename                    pic x(...).
01  status-return               pic s9(5).
    88 is-ok                    value 0.
    88 is-arg-error             value 9997.
    88 is-wrong-no-args         value 9998.
    88 file-does-not-exist      value 9989.
    88 unexpected-exception     value 9999.

CBL_READ_FILE

USING file-handle, file-offset, byte-count, flags, buffer [RETURNING status-return]

Where:

01  file-handle                     pic x(4).
01  file-offset                     pic 9(9).
01  byte-count                      pic 9(9).
01  flags                           pic 9 binary(1).
01  buffer                          pic x(...).
01  status-return                   pic s9(5).
    88 is-ok                        value 0.
    88 is-arg-error                 value 9997.
    88 is-wrong-no-args             value 9998.
    88 handle-not-found             value 9989.
    88 insufficient-space-in-buffer value 9988.
    88 no-data                      value 9987.
    88 unexpected-exception         value 9999.

CBL_WRITE_FILE

USING file-handle, file-offset, byte-count, flags, buffer [RETURNING status-return]

Where:

01  file-handle                     pic x(4).
01  file-offset                     pic 9(9).
01  byte-count                      pic 9(9).
01  flags                           pic 9 binary(1).
01  buffer                          pic x(...).
01  status-return                   pic s9(5).
    88 is-ok                        value 0.
    88 is-arg-error                 value 9997.
    88 is-wrong-no-args             value 9998.
    88 handle-not-found             value 9989.
    88 insufficient-space-in-buffer value 9988.
    88 no-data                      value 9987.
    88 unexpected-exception         value 9999.

CBL_FLUSH_FILE

USING file-handle [RETURNING status-return]

Where:

01  file-handle     pic x(4).
01  status-return   pic s9(5).
    88 is-ok        value 0 false -1.

CBL_GET_RECORD_LOCK

USING  file-handle, file-offset, byte-count, [reserved] [RETURNING status-return]

Where:

01  file-handle         pic x(4).
01  file-offset         pic 9(9).
01  byte-count          pic 9(9).
01  status-return       pic s9(5).
    88 is-ok            value 0.
    88 is-arg-error     value 9997.
    88 is-wrong-no-args value 9998.
    88 handle-not-found value -1.
    88 not-locked       value -1.

CBL_FREE_RECORD_LOCK

USING  file-handle, record-offset, record-length, reserved [RETURNING status-return]

Where:

01  file-handle         pic x(4).
01  file-offset         pic 9(9).
01  byte-count          pic 9(9).
01  status-return       pic s9(5).
    88 is-ok            value 0.
    88 is-arg-error     value 9997.
    88 is-wrong-no-args value 9998.
    88 handle-not-found value 9989.
    88 cannot-release   value -1.

CBL_TEST_RECORD_LOCK

USING  file-handle, record-offset, record-length, reserved [RETURNING status-return]

Where:

01  file-handle                     pic x(4).
01  file-offset                     pic 9(9).
01  byte-count                      pic 9(9).
01  status-return                   pic s9(5).
    88 is-ok                        value 0.
    88 is-arg-error                 value 9997.
    88 is-wrong-no-args             value 9998.
    88 handle-not-found             value 9999.
    88 is-locked-by-other-process   value 1.
    88 can-be-locked                value 0.
    88 cannot-be-locked             value 9999.

1 Micro Focus is trademark of Micro Focus Group, Ltd.