function saveLocalFile (fpath, data) {
    if (typeof ActiveXObject != "undefined") {
        fso = new ActiveXObject("Scripting.FileSystemObject");
	if(fso.FileExists(fpath)){
		var f = fso.GetFile(fpath);
		if (f.attributes & 1){ f.attributes = f.attributes - 1;}
		fso.DeleteFile(fpath);
		}
        var f = fso.CreateTextFile(fpath, true);
        f.write(data);
        f.Close();
        }
    else {
        if (top.widget) {
            var com;

            if (fpath.indexOf('$') != -1) {
                fpath = thisWidget + "/" + fpath;
                }

            com = "/usr/bin/perl write.pl \"" + fpath + "\" '" + escape(data) + "'";
            top.widget.system(com, null);
            }
        }
    }
