Thursday, 23 October 2008

framework.system.filesystem

Making a bit of progress now - framework.system.filesystem look like it should do what I want.
I have tried this:
function buttonClicked() {
debug.trace("ButtonClicked");
fname=framework.BrowseForFile("*|*.*");
oFs = framework.system.filesystem;
alert("oFs="+oFs);
if oFs.FileExists(fname) {
alert("file exists!");
oFile = oFs.GetFile("/home/graham/Countdown.js");
oStream = oFile.OpenAsTextStream(1,-2);
linstr = oStream.ReadLine;
alert("ofile="+ofile+" linstr="+linstr);
} else {
alert("file "+fname+" does not exist");
}
}
It looks promising - oFs is a real native object, which is encouraging, but I get an 'uncaught exception' error - still needs some digging into how it works!

Wednesday, 22 October 2008

gadget.storage.openText()

A bit of progress with local file access.
It is nice and easy to get a file browser to open to select a file name, using framwork.BrowseForFile().
Still can't read it though. The nearest I have found is gadget.storage.openText(), which works nicely reading files stored in the gadget .gg file, but I can't get it to open other files....
Code for a simple button to demonstrate the above:

function buttonClicked() {
debug.trace("ButtonClicked");
fname=framework.BrowseForFile("*|*.*");
debug.trace("fname="+fname);

file=gadget.storage.openText("main.xml");

alert("file="+file);
}
Unfortunately code.google.com seems to be dead, or I was going to ask on the developer's forum....

Tuesday, 21 October 2008

Google Desktop Gadgets

I've just discovered Google Desktop Gadgets. This site is for me to record things I have tried, so I can find them again.
Desktop Gadgets are simple javascript applications that run on Windows, Linux or Mac, which is neat. I use the Linux version.

A gadget is a simple zip file renamed to have a .gg extension. As a minimum it needs to contain three files, gadget.gmanifest, main.xml and main.js. .

gadget.gmanifest is a little file describing the gadget, so the Google Desktop application knows what to do with it.
main.xml defines the user interface of the gadget.
main.js is hte javascript code to provide the functionality.

When you install a gadget you get a warning saying that the gadget is being granted access to the local file system. This is good because the reason I am interested in them is that I have a web application which is a GPX route editor (http://www.maps.webhop.net) but I would like it to have access to the local file system so it can save its output file for you to put on your GPS device. I think it should be possible to port the application to work as a Gadget so it will retain its network capability with local file access.
It's just a matter of making it work.....

I am struggling to make local file access work, never mind anything more complicated!