Arrays and JScript 
Author Message
 Arrays and JScript

I have the following code:

var oMsg = new ActiveXObject("Util.Msg");

var a = new Array();
a[0] = "user x" ;
a[1] = "ip x" ;
//...
// And now comes the problem :
oMsg.setValues(a);

/*
I have built a com class with vj++ named Util.Msj that has the method
setValues(...)
First i tried this way : setValues(com.ms.com.Variant [] va), it didn't
work.
Now i'm using:

public void setValues(com.ms.com.Variant v)
{
/*
i don't know how to get the JScript array from the variant !
i only know that v.getvt() returns the value 9, that i found to be the
IDispatch type !
i just want to cast the variant to something like Variant [] or String [],
if i can get the Variant []
i hope to do va[0].toString() and get the string  "user x"
If there is a easy way to pass JScript Arrays to Com Objects implemented
with vj++  please let me know !
*/
//...
 }




Tue, 02 Sep 2003 08:48:22 GMT  
 Arrays and JScript
Asked and answered in the ...scripting.jscript newsgroup

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> I have the following code:

> var oMsg = new ActiveXObject("Util.Msg");

> var a = new Array();
> a[0] = "user x" ;
> a[1] = "ip x" ;
> //...
> // And now comes the problem :
> oMsg.setValues(a);

> /*
> I have built a com class with vj++ named Util.Msj that has the method
> setValues(...)
> First i tried this way : setValues(com.ms.com.Variant [] va), it didn't
> work.
> Now i'm using:

> public void setValues(com.ms.com.Variant v)
> {
> /*
> i don't know how to get the JScript array from the variant !
> i only know that v.getvt() returns the value 9, that i found to be the
> IDispatch type !
> i just want to cast the variant to something like Variant [] or String [],
> if i can get the Variant []
> i hope to do va[0].toString() and get the string  "user x"
> If there is a easy way to pass JScript Arrays to Com Objects implemented
> with vj++  please let me know !
> */
> //...
>  }





Tue, 02 Sep 2003 22:41:51 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Arrays and JScript

2. can I type cast byte arrays with jscript?

3. Multi Dimensional Arrays in Jscript (ASP)

4. Returning Variants That Contains an Array to JScript

5. is new Array() in JScript 1.0

6. Accessing Java applet array via JScript

7. Passing Array from JScript to COM Server

8. Excel Arrays in JScript

9. Passing Array from JScript to COM Server

10. Passing Arrays from jscript to c#

11. Return VB arrays to JScript (WSC under WSH - I think)

12. retrieve reocrds in an array using Jscript

 

 
Powered by phpBB® Forum Software