XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 2nd, 2025, 5:26 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: May 27th, 2017, 1:58 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
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!


Top
 Profile  
 
PostPosted: June 21st, 2017, 3:09 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
I've created a widget using the above code to write and read a sample file.

Image


Attachments:
writeansifile.xwp [57.14 KiB]
Downloaded 350 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 35 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group