0

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!

4
  • 1
    What browser(s) are you trying this on? Commented Jan 18, 2010 at 17:31
  • 1
    If you are in IE, you are using JScript and not JavaScript (which is Mozilla's implementation). The VBArray constructor should be available. Commented Jan 18, 2010 at 18:14
  • p. sure that "JScript" is just the name Microsoft uses for the interpreter that runs what everybody else calls "Javascript" Commented Jan 18, 2010 at 18:14
  • Thanks to everyone for the responses! I'm using IE. So if my tag is <script language="JavaScript">, in IE, that's really the same as <script language="JScript">? I had no idea, really. I've never had to use ActiveX components before, a whole new world for me (coming from EJB and Java middleware - think my brain is hemorrhaging). Commented Jan 18, 2010 at 18:31

1 Answer 1

2

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>" );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.