26-Sep-2009

Callable copy

Here's how to copy a file using the Convert API in COBOL.


identification division.
program-id. copy_file with ident "X01-00".
author.  James F. Duff.
date-written. 26-Sep-2009.

environment division.

data division.
working-storage section.
01 ret_status pic s9(09) comp.
linkage section.
01 input_file pointer.
01 output_file pointer.

procedure division using input_file, output_file giving ret_status.
00-begin.

    call "conv$pass_files" using by reference input_file,
                                 by reference output_file,
                                 omitted,
                                 omitted,
                                 omitted
                           giving ret_status.
    if ret_status is failure
        go to 01-end
    end-if.

    call "conv$pass_options" using omitted,
                                   omitted
                             giving ret_status.
    if ret_status is failure
        go to 01-end
    end-if.

    call "conv$convert" using omitted,
                              omitted,
                              omitted
                        giving ret_status.

01-end.
    exit program.

Posted at September 26, 2009 3:44 PM
Tag Set:

Comments are closed