Software Archive
Read-only legacy content
17060 Discussions

Problem While returning an array from CVF COM dll to ASP page....

Intel_C_Intel
Employee
435 Views
Hi friends,
I have written a COM component in Fortran.I am getting an error message while I am calling one of the function of that component in my ASP page.The error message I am getting is

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'xx'
/fortran/chk.asp, line 11

I am attaching both my fortran code and asp code for better understanding of the problem.

Fortran Code
************* 
! 
!  UItestclass.f90 - This file contains the implementation of the 
!                    Itestclass methods 
! 
    ! Itestclass_xx 
    function Itestclass_xx( ObjectData ,& 
			 y,& 
			 x) result (hresult) 
        use testclass_Types 
		use dfwinty 
		use oleaut32 
        implicit none 
        type(testclass_InstanceData) ObjectData 
        !dec$ attributes reference :: ObjectData 
        TYPE(VARIANT), intent(inout) :: y 
        DIMENSION y(0:2) 
        integer(4), intent(in) :: x 
        integer(LONG) hresult 
        ! TODO:  Add implementation 
 
		call VariantInit(y(0)) 
		y(0)%vt = VT_R8 
		y(0)%vu%DOUBLE_VAL =1.8  
		call VariantInit(y(1)) 
		y(1)%vt = VT_R8 
		y(1)%vu%DOUBLE_VAL =2.6 
		call VariantInit(y(2)) 
		y(2)%vt = VT_R8 
		y(2)%vu%DOUBLE_VAL =3.6 * x 
		 
		 
        hresult = S_OK 
    end function 
 
ASP code 
*********** 
")
Response.Write(y(1) & "
") Response.Write(y(2) & "
") %>


In my fortran code while I am removing the input input parameter,I am able to get the array value in the asp page.

I will be glad if I will get any suggestion to solve the problem.

Thanks

Debaprasad Tripathy

Timken Engg. And Research India Pvt. Ltd.
0 Kudos
1 Reply
Intel_C_Intel
Employee
435 Views
Hi,

The problem is that scripting clients send arrays as a Variant containing a Safearray of Variants. In your code, the interface method is expecting just a SafeArray of Variants. That is your type mismatch.

Once you straighten that out, you'll have to do the fun defensive coding dealing with variant args. Like whether or not the variant was passed with VT_BYREF which affects getting access to the safeArray pointer in the variant. And like whether or not the variant elements of the safearray really are of the type you're expecting. And what method will you use to access the SafeArray of variants in Fortran.

IMO, writing COM code for scripting clients is a pain in the neck, independent of the programming language. FWIW, this gets better in .NET.

hth,
John
0 Kudos
Reply