Hello,
I recently got into PHP/COM and so I created a VB6 COM DLL to use as a wrapper for some FinCAD DLL's I need to call, but having problems in the area of parameter passing into and out of the VB wrapper on three specific issues. I also tested a IIS/ASP version of this script which works fine (or as expected) with this COM, but I can't use ASP for this project.
Problem:
1) I can only receive output data from the DLL function thru a single Function result value and not thru function parameters used by reference.
2) I can not pass a PHP array into DLL function, my every attempt is met with 'Invoke() failed: Type mismatch.'
3) I can not receive an array as a result of calling a function, although VB 6 allows passing arrays as result of functions.
I'm posting my sample COM object and working ASP and broken PHP which I'm using to test this COM wrapper.
My setup is: Win2K, IIS5, PHP 4.0.5 installed as CGI
VB6 COM PROGRAM:
Public Function foo(ByVal in_var As Variant, ByRef out_arr() As Variant, ByRef out_var As Variant) As Variant
' just do something
' swap input/ouput array elements
t = out_arr(0)
out_arr(0) = out_arr(1)
out_arr(1) = t
out_var = in_var ' update output parm with input parm
foo = in_var ' return input parameter as function value
End Function
WORKING ASP SCRIPT:
<% Option Explicit
dim ob
dim arr(1)
dim invar
dim outvar
dim funcvalue
invar = 123
outvar = 0
arr(0) = 11
arr(1) = 22
Set ob = CreateObject("COMTEST.Tester")
funcvalue = ob.foo( invar, (arr) , outvar )
Set ob = Nothing
%>
<HEAD>
<TITLE>ASP/COM Tester</TITLE>
</HEAD>
<BODY>
<%
Response.Write "<P>ASP COMTEST.Tester.foo(invar=123,arr=(11,22),outvar=0) <b>expected</b> funcvalue=123, invar=123, arr(0)=22, arr(1)=11, outvar=123"
Response.Write "<P>ASP COMTEST.Tester.foo(invar=123,arr=(11,22),outvar=0) <b>received</b> funcvalue=" & funcvalue & ", invar=" & invar & ", arr(0)=" & arr(0) & ", arr(1)=" & arr(1) & ", outvar=" & outvar
%>
</BODY>
NON-WORKING PHP SCRIPT:
<?
$invar = "123";
$outvar = "0";
$arr = Array(0,0);
$arr[0] = "11";
$arr[1] = "22";
$ob = new COM("COMTEST.Tester");
$funcvalue = $ob->foo( $invar, &$arr[], &$outvar );
unset($ob);
?>
<HEAD>
<TITLE>PHP/COM Tester</TITLE>
</HEAD>
<BODY>
<?
echo "<P>PHP COMTEST.Tester.foo(invar=123,arr=(11,22),outvar=0) <b>expected</b> funcvalue=123, invar=123, arr(0)=22, arr(1)=11, outvar=123";
echo "<P>PHP COMTEST.Tester.foo(invar=123,arr=(11,22),outvar=0) <b>received</b> funcvalue=" . $funcvalue . ", invar=" . $invar . ", arr[0]=" . $arr[0] . ", arr[1]=" . $arr[1] . ", outvar=" . $outvar;
?>
</BODY>
WHAT AM I DOING WRONG?
PLEASE, HELP