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]);
}
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]);
}