Xwidget engine does not have any capability to write a standard ANSI file! It has the readfile function where it can read ANSI data from a selected file but it cannot write that data back again...
I had always assumed there was a writeFile function to act as the opposite to the readFile function but there isn't. I assumed this as every other engine has an equivalent function - in the Yahoo widget engine we would use:
Code:Code:
filesystem.writeFile(XMLpath, head + body + tail);
This command writes the file located by XMLpath and then places the data represented by head, body and tail into the file. There is no direct replacement for this command. So this leaves us with the task of creating this function from scratch using ActiveX. Luckily Jscript provides ActiveX access to the FileSystemObject
Code:Code:
filesystemWriteFile(XMLpath, head + body + tail);
Code:
//=================================
//function to write an ANSI file
//=================================
function filesystemWriteFile(writePath,writeData)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile(writePath, 2, true);
fh.WriteLine(writeData);
fh.Close();
}
//=================================
// end function
//=================================
This code successfully replicates Xwidget's missing writeFile functionality and allows Xwidget to write standard output just as any other widget engine can. Phew!
Naming the new function filesystemWriteFile means that any conversion of an Yahoo widget that uses the filesystem.writeFile code is much easier. These type of translated functions can be added to any Xwidget and the simple removal of a '.' will make the old yahoo widget code compatible.
This small bit of code serves as an example as to how easy it would be to create this functionality natively within Xwidget. It ought to be done in C++ and not in ActiveX. I still cannot believe that Xwidget provides the functionality to read an ANSI file but not the ability to write one!