Click to See Complete Forum and Search --> : Calling the Gurus - NetScape Issues (ver7.0)


vincentms
05-02-2003, 01:05 PM
Hello all,

I have been cruising along with my little project for the last 10 days or so...doing just fine. Today I have tried to get my appl. first to work with NetScape and eventually I want it to run on Linux.

This function works fine under IE, but is not working with NS. I think it has to do with ActiveXObject or something. That statement bombs out. I dont know exactly why, only that if I insert 2 alerts, 1 just before and one just after the statement: var fso = new ActiveXObject("Scripting.FileSystemObject");

Well the 1rst alert is seen and the 2nd one NOT!!!

As you can perhaps tell this simple function reads a CSV file and loads the content into an array for later use.

If I must use another type of logic to be compatible with both browsers, please tell me, or better yet show me.

Thanks in advance,
Vincent

Zürich Switzerland


function getNext() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var myFile = fso.OpenTextFile("C:\\ExamCabinet\\Data\\Bahgdad.txt", 1, false);
var inputArray;
inputArray = myFile.ReadLine().split(';')

for( var i = 0; i < inputArray.length; i++ ) {
arrayNames[i]= inputArray[i];
globalArray[arrayNames[i]]= new Array;
}

var rowNum = 0;

while (!myFile.AtEndOfStream) {
inputArray = myFile.ReadLine().split(';');

for( i = 0; i < inputArray.length; i++ ) {
globalArray[arrayNames[i]][rowNum] = inputArray[i]
}
rowNum +=1;
}
myFile.Close();
alert(globalArray[arrayNames[3]][1]);
}

khalidali63
05-02-2003, 01:47 PM
Hey Vincent,
too bad, ActiveXControls are only IE specific.NS does not support them.
You will have to resort to another logic.that said,
JavaScript does not have the ability to read or write from the hard drive,so you are out of luck there as well.however if you search the forum you may be able to find a Java solution that will work for both NS and IE.

gil davis
05-02-2003, 01:48 PM
I think it has to do with ActiveXObjectThat object is IE-only. There is nothing like it in ECMAScript or JavaScript.

If you open the javascript console (Tasks|Tools|Javascript Console), you should see an error for the line that establishes the object.

vincentms
05-02-2003, 02:21 PM
Was I clear?

I actually don't want to read from the local hard drive (as I am doing in the function), but actually I want read a CSV file on the server.

Is the answer still "JS doesn't do this."

Thanks guys,
Vincent
Zürich, Switzerland