Previous Topic Next topic Print topic


cobput

Converts data from native C language types to COBOL types. There are a number of cobput functions, each for a different type of COBOL data.
Restriction: This function is supported for native COBOL only.

Syntax:

include "cbltypes.h"    /* Includes cbltypes.h and cobgetput.h */

void        cobput_x1_compx(cbl_x1_compx_t *cbldata, cobuns8_t val);
void        cobput_x2_compx(cbl_x2_compx_t *cbldata, cobuns16_t val);
void        cobput_x4_compx(cbl_x4_compx_t *cbldata, cobuns32_t val);
void        cobput_x8_compx(cbl_x8_compx_t *cbldata, cobuns64_t val);

void        cobput_x1_comp5(cbl_x1_comp5_t *cbldata, cobuns8_t val);
void        cobput_x2_comp5(cbl_x2_comp5_t *cbldata, cobuns16_t val);
void        cobput_x4_comp5(cbl_x4_comp5_t *cbldata, cobuns32_t val);
void        cobput_x8_comp5(cbl_x8_comp5_t *cbldata, cobuns64_t val);

void        cobput_sx1_comp5(cbl_sx1_comp5_t *cbldata, cobs8_t val);
void        cobput_sx2_comp5(cbl_sx2_comp5_t *cbldata, cobs16_t val);
void        cobput_sx4_comp5(cbl_sx4_comp5_t *cbldata, cobs32_t val);
void        cobput_sx8_comp5(cbl_sx8_comp5_t *cbldata, cobs64_t val);

void        cobput_xn_comp5(cbl_x1_t *cbldata, cobuns8_t n, cobuns64_t vall);
void        cobput_xn_compx(cbl_x1_t *cbldata, cobuns8_t n, cobuns64_t val);

void        cobput_sxn_comp5(cbl_x1_t *cbldata, cobuns8_t n, cobs64_t val);

void        cobput_pointer(cbl_pointer_t *cbldata, void *val);
void        cobput_ppointer(cbl_ppointer_t *cbldata, PFR val);

Parameters:

cbldata Pointer to the COBOL data item and data description as indicated by the cobget function name.
val Value to be placed in the COBOL data item cbldata.

Comments:

The cobput_xn_compx functions enable you to put data into data items with descriptions such as PIC X(3).

Equivalent COBOL Syntax:

None.

Example:

COBOL program:

program-id.  mycblprog.

 copy "cbltypes.cpy".
 
 01  myrec.
      05 myrec-key   		cblt-x4-compx value 10.
 procedure division.
     call 'mycprog'  using myrec-key
     if  myrec-key = 20
         display "First call to 'mycblprog'"
     else
         display "Subsequent call to 'mycblprog'"
     end-if
     exit program
 end program mycblprog.

C program:

#include "cbltypes.h"
 void
 mycprog(cbl_x4_compx_t *cbldata)
 {
  cobput_x4_compx(cbldata, cobget_x4_compx(cbldata) + 10);
 }
Previous Topic Next topic Print topic