Passing Array from JScript to COM Server 
Author Message
 Passing Array from JScript to COM Server

We want to pass a VarArray from JScript to A delphi COM Exe Server.
We made it in this way:
(Script)
var ParmTyp = new Array(0,1,2,0,0,0,0);

var Error = PhyObject.Run_Script(ScriptFileName, Times, LogFile, ParmTyp);

In server we  receive IDispatch variable and want to cast to varArray or any
other array, how can we made this.
We succeed to cast to concatenate string but not to array.
Thanks, Igal.
P.D. From VB Script we have not any problem, what's the difference?



Fri, 11 Feb 2005 17:14:57 GMT  
 Passing Array from JScript to COM Server
The problem is that a JScript array isn't a VB Safe Array. It's a JScript
Object. Strangely, though MS has provided a means to use Safe Arrays in
JScript (the VBArray object), they haven't provided a way to convert a
JScript array to a Safe Array similar to the JScript Date object's
getVarDate method.

Fortunately, someone has felt your pain. Peter Torr has written an ActiveX
component to convert JScript arrays to Safe Arrays.

http://www.netspace.net.au/~torrboy/code/jsafearr/

--
Too many people spend money they haven't earned, to buy things they don't
want, to impress people they don't like. -Will Rogers

=-=-=
Steve
-=-=-


Quote:
> We want to pass a VarArray from JScript to A Delphi COM Exe Server.
> We made it in this way:
> (Script)
> var ParmTyp = new Array(0,1,2,0,0,0,0);

> var Error = PhyObject.Run_Script(ScriptFileName, Times, LogFile, ParmTyp);

> In server we  receive IDispatch variable and want to cast to varArray or
any
> other array, how can we made this.
> We succeed to cast to concatenate string but not to array.
> Thanks, Igal.
> P.D. From VB Script we have not any problem, what's the difference?



Fri, 11 Feb 2005 19:21:30 GMT  
 Passing Array from JScript to COM Server

Quote:

> We want to pass a VarArray from JScript to A Delphi COM Exe Server.
> We made it in this way:
> (Script)
> var ParmTyp = new Array(0,1,2,0,0,0,0);

> var Error = PhyObject.Run_Script(ScriptFileName, Times, LogFile,
> ParmTyp);

> In server we  receive IDispatch variable and want to cast to varArray
> or any other array, how can we made this.
> We succeed to cast to concatenate string but not to array.
> Thanks, Igal.
> P.D. From VB Script we have not any problem, what's the difference?

Steve already explained the difference and gave to one solution (Peter
Torr's).

Here's another way tha JScript can create a VBScript-style SAFEARRAY...

var ParmTyp = new Array(0,1,2,0,0,0,0);
var sdParmTyp = new ActiveXObject("Scripting.Dictionary");
for(var i=0; i<ParmTyp.length; i++){sdParmTyp.item(i) = ParmTyp[i]}

// sdParmTyp.items(); will return a SAFEARRAY
var Error = PhyObject.Run_Script(ScriptFileName, Times, LogFile,
sdParmTyp.items());

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 12 Feb 2005 04:17:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing Array from JScript to COM Server

2. Passing arrays to COM java objects from JScript (Server Side)

3. Problem retrieving members of array passed from COM Server

4. Passing array from COM server to VBScript client

5. Passing array of strings from ASP (JScript) to ATL COM

6. Modifying JScript array from COM server?

7. Passing Server Array to Client JScript

8. passing jscript arrays TO Automation servers

9. Passing arrays from a server-function/sub to a server -variable

10. Help converting server-side VBScript array into client-side JScript array

11. Passing a vjscript byte array to a C++ COM object

12. Passing an Array object to a C++ COM object

 

 
Powered by phpBB® Forum Software