Monday, November 08, 2010 at 12:05 AM.

on compactDataFiles (flKillThreads=true) {
		<<3/14/02; 5:16:58 PM by JES
			<<Skip files that don't have a .root extension.
		<<1/5/02; 7:43:33 AM by DW
			<<Kill all threads before compacting, restart them when we're done.
		<<1/4/02; 2:16:59 PM by DW
			<<Created. Loops over all the folders in the Data Files sub-folder of the Radio UserLand folder, compacting all the databases. It has to coordinate with frontier.opendatafile so that it doesn't open one of the files while it's being compacted. This is not a perfect utility, there are circumstances when it will fail to compact a file. However, any ills created by this script can be cured by quitting and relaunching. It's designed to run from a menu command and not run very frequently.
	local (folder = frontier.pathstring + "Data Files" + file.getpathchar ());
	local (adrtable =;
	local (ftmp = folder + "tmp.root");
	window.about ();
	if file.exists (ftmp) {
		try {filemenu.close (f)};
		try {file.delete (ftmp)}};
	if flKillThreads {
		user.scheduler.prefs.runThreads = false;
		scheduler.monitorThreads ()};
	local (f);
	fileloop (f in folder) {
		local (fname = file.filefrompath (f));
		if not (string.lower (fname) endsWith ".root") {
		local (adrdata = frontier.opendatafile (string.popsuffix (fname)));
		local (adr);
		for adr in adrtable {
			if adr^.f == f {
				adr^.flCompacting = true; //so frontier.opendatafile won't open it
		msg ("Compacting data file \"" + fname + "\".");
		try {
			local (oldtarget = target.set (adrdata));
			filemenu.savemyroot (adrdata);
			filemenu.savecopy (ftmp);
			target.set (oldtarget);
			filemenu.close (f);
			file.delete (f);
			file.rename (ftmp, fname); (f, hidden:true)};
		delete (@adr^.flCompacting); //it's okay to open it now
		msg ("")};
	if flKillThreads { //restart threads
		user.scheduler.prefs.runThreads = true;
		scheduler.monitorThreads ()};
	if file.exists (ftmp) {
		try {filemenu.close (f)};
		try {file.delete (ftmp)}}};
bundle { //test code
	compactDataFiles ()}

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.