views:

225

answers:

1

I have an ActiveX component (which I did not write and have no control over). It has several methods I want to use, which return arrays. Every time I attempt to do something of the sort:

var arrayValue = axObj.methodWhichReturnsArray();

the arrayValue object is undefined. The component provider tells me that I should not be having any of the problems I'm describing. I do perform a null check which it passes (meaning the axObj is not null).

The component provider, however, is using JScript, not JavaScript, in his example, which goes something like

var arrayVar = axComponent.getListAsArray();
var theArray = (new VBArray(arrayVar)).toArray();
alert(theArray[0]);
alert(theArray[1]);
alert(theArray[2]); 

But again, I am using JavaScript (and have never used JScript) so am not sure of what the difference is...

(And I am a weathered Java veteran, so all of it is frustrating.)

Thank you!

A: 

JScript is Microsofts version of Javascript from "back in the day" and is still going strong.

First question has to be where are you trying to use it? In the browser? Intranet? IE only? Server-side?

JScript is not available in anything other than IE or on a IIS Server or MS desktop machine so I hope you are running it on one of the above.

JScript has a special function in it for converting VBScript arrays to JScript arrays (as they are stored differently) which is the VBArray function in your code.

You might be able to get around this by using an JScript Enumerator http://msdn.microsoft.com/en-us/library/6ch9zb09(VS.85).aspx

Something like (although untested):

var fso = new ActiveXObject("Scripting.FileSystemObject");
var e = new Enumerator(fso.Drives);
var myArray = [];
do {
 myArray.push( e.item() );
 e.moveNext();
} while ( !e.atEnd() );

document.write( myArray.join( "<li>" );
Pete Duncanson