ASP & Visual C++ SafeArrays? 
Author Message
 ASP & Visual C++ SafeArrays?

I have an Visual C++ COM object with a function that's returning a SafeArray
of Strings in a VARIANT*.  I can use the function in Visual Basic and access
each item in the array without difficulty.  When I try to implement the same
fuction in ASP/VBScript I get a "Type Mismatch" error when I try to access
the individual items of the array.

An array is being returned... I can see the individual array items in the
Locals Window and the IsArray function returns True.

Any Ideas?

Thanks in advance.



Fri, 10 May 2002 03:00:00 GMT  
 ASP & Visual C++ SafeArrays?
Could it be that VBScript would like it to be an array of variants of type
string instead?
(I have a vauge memory of reading something like that.)

J?rgen Lindell

Quote:

>I have an Visual C++ COM object with a function that's returning a
SafeArray
>of Strings in a VARIANT*.  I can use the function in Visual Basic and
access
>each item in the array without difficulty.  When I try to implement the
same
>fuction in ASP/VBScript I get a "Type Mismatch" error when I try to access
>the individual items of the array.

>An array is being returned... I can see the individual array items in the
>Locals Window and the IsArray function returns True.

>Any Ideas?

>Thanks in advance.




Sun, 12 May 2002 03:00:00 GMT  
 ASP & Visual C++ SafeArrays?
Yep,

Jorgen got it right on the money! Your safearray has to be one of variants.
I had this problem once with methods returning safearrays of doubles. Since
I did not want to rewrite my COM server, I just wrote a shim object in VB
with only one default property which is a variant containing an araay of
variants. You would use it as such:

Dim vbArray as New MyShim

Set vbArray = OtherObject.TheTroublesomeMethod()

or

Set vbArray.Data = OtherObject.TheTroublesomeMethod()

then you can play around with vbArray as you wish. If you take care of
making Data the default property, you can write code as

For i = LBound(vbArray) To UBound(vbArray)
    Response.Write vbArray(i)
Next i

--

----------------------------------------------------------------------------
--------------
Jacques Rioux
Associate Professor of Actuarial Science
Drake University

(515) 271-1894

Quote:
> Could it be that VBScript would like it to be an array of variants of type
> string instead?
> (I have a vauge memory of reading something like that.)

> J?rgen Lindell


> >I have an Visual C++ COM object with a function that's returning a
> SafeArray
> >of Strings in a VARIANT*.  I can use the function in Visual Basic and
> access
> >each item in the array without difficulty.  When I try to implement the
> same
> >fuction in ASP/VBScript I get a "Type Mismatch" error when I try to
access
> >the individual items of the array.

> >An array is being returned... I can see the individual array items in the
> >Locals Window and the IsArray function returns True.

> >Any Ideas?

> >Thanks in advance.




Mon, 13 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ASP & Visual C++ SafeArrays?

2. Visual C++ & Visual Age c++

3. visual basic & safearray

4. Visual Basic & Visual C++ Programmers required

5. Visual Basic & Visual C++ Programmers required

6. Visual Basic & C++

7. transfering data between vb5 & visual C++

8. visual basic & c++ differences

9. Visual Basic & C++

10. directx9.0 sdk installation & visual c++ 6.0

11. Safearray write using ASP

12. Visual C++ and Visual Basic and Visual J++

 

 
Powered by phpBB® Forum Software