getActiveXObject couldn't close file
Hi guys,
I'm using getActiveXObject to parse an xml file.
This instruction is in a function, when I call this function twice, I have an error, I suppose because file is already open.
So there is a method like 'close', I need to close and reopen this file n-times.
Here is the function.
function Translate_Msg_Static(MessageKey) // Translate a dinamic message
{
var Doc, s, ChildNode, Path;
Doc = getActiveXObject("Msxml2.DOMDocument.6.0");
Doc.async = false;
// Load data from a file
// We use the file created earlier
Doc.setProperty("ProhibitDTD", false);
Doc.load(Get_Translate_Mgs_Static_File());
// Report an error, if, for instance, the markup or file structure is invalid
if(Doc.parseError.errorCode != 0)
{
s = "Reason:\t" + Doc.parseError.reason + "\n" +
"Line:\t" + aqConvert.VarToStr(Doc.parseError.line) + "\n" +
"Pos:\t" + aqConvert.VarToStr(Doc.parseError.linePos) + "\n" +
"Source:\t" + Doc.parseError.srcText;
// Post an error to the log and exit
Log.Error("Cannot parse the document.", s);
return;
}
// Catch dinamically the path to search
Path = "//translation[@id='" + MessageKey + "']";
// Search single node
ChildNode = Doc.selectSingleNode(Path);
// If node exists then translate message else return messagekey
if (ChildNode != null)
return ChildNode.text;
else
return MessageKey
}
thanks in advantage
I got it, I found the bug.
Original:
function Get_Translate_Mgs_Static_File() // Get static file { if (Const_lib.Language== "it") return Get_Translate_Mgs_Static_File = "c:\\DL Console\\messages.it.xtb" else if (Const_lib.Language== "en_US") return Get_Translate_Mgs_Static_File = "c:\\DL Console\\messages.xtb" }
Now workfunction Get_Translate_Mgs_Static_File() // Get static file { if (Const_lib.Language== "it") return "c:\\DL Console\\messages.it.xtb" else if (Const_lib.Language== "en_US") return "c:\\DL Console\\messages.xtb" }
Tanks