Highlighted
Super Contributor.
Super Contributor.
304 views

Pass PIC N(n) in safearray to COM object

I am creating this safearray (for pass to COM object):

           move VT-BSTR to w-vartype
           move 1 to w-dimension
           compute w-y = a-x * 2
           move w-y to cElements of w-saBound(1)
           move 0 to llBound of w-saBound(1)
           invoke OLESafeArray "new"
            using by value w-vartype w-dimension
            by reference w-saBound(1)
            returning w-accArray
           end-invoke
           move a-x to cElements of w-saBound(1)
           invoke OLESafeArray "new"
            using by value w-vartype w-dimension
            by reference w-saBound(1)
            returning w-modArray
           end-invoke

           initialize w-x
           perform varying w-Index from 0 by 1 until w-Index >= w-y
             add 1 to w-x
             move n'aaa' to acc-bank-acc-num
             invoke w-accArray "putString"
              using by reference w-Index
                    by value 68
                    by reference w-acc-num(w-x)
              returning w-hresult
             end-invoke
             add 1 to w-Index
             invoke w-accArray "putString"
              using by reference w-Index
                    by value 68
                    by reference w-acc-result(w-x)
              returning w-hresult
             end-invoke
           end-perform

           perform varying w-Index from 0 by 1 until w-Index >= a-x
             invoke w-modArray "putString"
              using by reference w-Index
                    by value 4
                    by reference w-acc-mod(w-Index + 1)
              returning w-hresult
             end-invoke
           end-perform

When I am passing PIC X(n) variables (in sample w-acc-num, w-acc-result, etc.) everything is ok. But I need to process Unicode strings, so data type must be PIC N(n). And then result in COM object (.NET C#) is bad, for example like this:

  • I am sending 1072907036
  • But in COM object I receive 1\00\07\02\09\00\07\00\03\06\0

I suppose, that problem is in type VT_BSTR, should I you VT_VARIANT instead? And if it so, how to properly use safearray of VT_VARIANTs? And I also returning this array back to Cobol.

0 Likes
0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.