Wednesday, December 22, 2010 at 11:00 AM.

workspace.userlandSamples.exportWorkspace

<<Changes
	<<12/22/10; 10:01:47 AM by DW
		<<This script is a step on the path to making it easy to start with a fresh OPML installation. It exports all the parts of your workspace table. Bonus -- it also exports the sub-tables of your user table.
local (pc = file.getpathchar (), folder = frontier.pathstring + "Workspace backup" + pc);
on saveobject (adr, folder) {
	local (suffix = Frontier.getFileSuffix (typeOf (adr^), true));
	if suffix != "" {
		suffix = "." + suffix};
	s = nameof (adr^);
	adrParent = parentOf (adr^);
	if adrParent != nil {
		if (not table.inguestdatabase (adr)) or (adrparent != table.getrootaddress (adr)) {
			local (dottedname = nameOf (adrParent^) + '.' + s);
			if (sizeof (dottedname) + sizeof (suffix) + 1) < 32 {
				s = dottedname}}};
	local (f = folder + s + suffix);
	file.surefilepath (f);
	export.sendobject (adr, f);
	file.setmodified (f, timemodified (adr));
	file.setcreated (f, timecreated (adr))};
on savetable (adrtable, folder) {
	local (adr);
	for adr in adrtable {
		saveobject (adr, folder + nameof (adrtable^) + pc)}};
savetable (@workspace, folder);
savetable (@user, folder)



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.