1

I am trying to call CAPL function from Python giving char array as argument in python by taking reference: Call CAPL function from Python

But it throws error

function1.Call(my_char_array) File "C:\Python27\lib\site-packages\win32com\gen_py\4CB02FC0-4F33-11D3-854D-00105A3E017Bx0x1x31.py", line 1668, in Call , p7, p8, p9, p10) File "C:\Python27\lib\site-packages\win32com\client__init__.py", line 467, in ApplyTypes self.oleobj.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352571), 10)

I am not able to pass char in function from Python to CAPL function. Passing Integer works. Any help would be much appreciated.

Code Snippet:

Python:

    var = 'ABCD'
    my_char_array = array('c', var)
    print my_char_array.tostring()
    function1.Call(my_char_array)

CAPL:

void function1(char var1[])
{
    write("function1() called with %s!", var1);
}
aL_eX
  • 1,453
  • 2
  • 15
  • 30

1 Answers1

2

It is explained in the Vector's documentation at the bottom of the page 15:

The number of input parameters is limited to 10 and it is not possible to pass on an array as a CAPL function parameter. It is practical to use input parameters of type Long in CAPL. In this case it is possible to pass on parameters from VB.NET/C# that are from types Byte (1 byte), Integer (2 bytes), and Long (4 bytes), without having to worry about the types matching up between VB.NET/C# and CAPL.

I had opportunity to use Python script to call CAPL functions and had to figure out that this applies to Python too.

blem14
  • 21
  • 4
  • as a side note, how did you pass long values from python? Passing 0xFFFFFFFF results in "No method matches given arguments for Call" error, whereas 0xFFFFFF does not raises errors. – Catosh Dec 12 '19 at 11:07