Skip to main content

I have this data type

01 aCharArray object reference.

It's VT-BSTR. How to pass it to standard PIC X(n) variable?


#nativecobol

I have this data type

01 aCharArray object reference.

It's VT-BSTR. How to pass it to standard PIC X(n) variable?


#nativecobol
I know about this article: https://supportline.microfocus.com/documentation/books/nx51ws01/dmolda.htm But there is only sample how to display such char array to command line.

I have this data type

01 aCharArray object reference.

It's VT-BSTR. How to pass it to standard PIC X(n) variable?


#nativecobol

In what way are you using this VT-BSTR? Are you passing it to a non-COBOL COM object? Normally you can just define these as standard COBOL PIC X fields and they will automatically be converted to BSTR by the run-time system when passing to a COM object and will be converted back to PIC X upon return.

A real simple example of how to convert between a CharArray type and a PIC X:

program-id. testchar. environment division. class-control. CharacterArray is class "chararry". working-storage section. 01 astring pic x(10) value "Chris". 01 asize pic s9(9) comp-5 value 5. 01 achararray object. 01 anewstring pic x(10) value spaces. procedure division. invoke CharacterArray "fromBuffer" using asize astring returning achararray end-invoke invoke achararray "getValue" returning anewstring display anewstring goback.