Forum Moderators: open
function readfile(filename)
{
var string = ""; objXml = new ActiveXObject("MICROSOFT.XMLHTTP");
objXml.open("POST", filename, true);
objXml.onreadystatechange=function()
{
if (objXml.readyState==4)
{
string = objXml.responseText;
}
}
objXml.send(null);
return string;
}
I then use strarray = string.split(/\*/); to get an array of my items and elemarray = strarray[i].split(/\,/); to get an array of each item in the entry. It reads in fine, and I have no problem parsing it and populating a form with this information.
The problem comes when I try to read in a file that is saved. I pull the modified information from a form, put it into a big string, adding the * and ' in the right place, and then save it to the same file using this code:
function write_file(string, filename)
{
SaveFrame.document.open("text/html","replace")
SaveFrame.document.write(string)
SaveFrame.document.close()
SaveFrame.focus()
SaveFrame.document.execCommand('SaveAs',false,filename)
} Where SaveFrame is just a non-displayed iframe. I looks like it writes all the infomation in fine, when I examine the file everything is there, all the seperators are in the right place, noting wrong with it at all.
However, when I try to read it in the saved file rather than the one I made, it only returns 1 entry with one array with 1 character in it: S. S happens to be the first character of the file, so I tried changing it, having made backups of the original databases, and it always returns the first character only of the file.
The only thing I can come up with is that when it asks me to save it, it defaults to Unicode. When saved in this method, I get the aboce results. When saved in "user defined", for example, it adds a whole bunch of extra data, but it reads the entire file. Maybe someone can explain whats going on. Thanks in advance.
BTW, this is for intranet use, so IE 6 specific solutions are just fine, its the only browser that will use this code. Thanks again.
SaveFrame.document.charset="UTF-8";