1

我正在尝试从 Python 调用 CAPL 函数,通过参考将 char 数组作为 Python 中的参数:Call CAPL function from Python

但它会引发错误

function1.Call(my_char_array) 文件“C:\Python27\lib\site-packages\win32com\gen_py\4CB02FC0-4F33-11D3-854D-00105A3E017Bx0x1x31.py”,第 1668 行,在 Call 中,p7、p8、p9、p10)文件“C:\Python27\lib\site-packages\win32com\client__init__.py”,第 467 行,在ApplyTypes self. oleobj .InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), pywintypes.com_error: (-2147352567, '发生异常。', (0, None, None, None, 0, -2147352571), 10)

我无法将函数中的字符从 Python 传递给 CAPL 函数。传递整数有效。任何帮助将非常感激。

代码片段:

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);
}
4

1 回答 1

2

在第 15 页底部的Vector 文档中对此进行了说明:

输入参数的数量限制为 10 个,并且不能将数组作为 CAPL 函数参数传递。在 CAPL 中使用 Long 类型的输入参数是实用的。在这种情况下,可以从 VB.NET/C# 传递来自 Byte(1 字节)、Integer(2 字节)和 Long(4 字节)类型的参数,而不必担心 VB 之间的类型匹配.NET/C# 和 CAPL。

我有机会使用 Python 脚本来调用 CAPL 函数,并且必须弄清楚这也适用于 Python。

于 2018-02-15T11:00:18.733 回答