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


on typersrc (path) {
	local (foundAtLeastOne = false);
	on loadFrom (path) {
		if file.isFolder (path) {
			local (f);
			fileloop (f in path) {
				if not loadFrom (f) {
					return (false)}}}
		else {
			msg (file.fileFromPath (path));
			on loadType (f, resType) {
				local (ct, i, resName, resData);
				ct = rez.countResources (f, resType);
				for i = 1 to ct {
					if rez.getNthResource (f, resType, i, @resName, @resData) {
						foundAtLeastOne = true;
						local (adrTable = @system.extensions);
						if not defined (adrTable^) {
							new (tableType, adrTable)};
						adrTable = @adrTable^.[resName];
						if not defined (adrTable^) {
							new (tableType, adrTable)};
						local (adrObject = @adrTable^.code);
						if not dialog.ask ("Address for new " + resType + "?", @adrObject) {
							return (false)};
						if defined (adrObject^) {
							if not dialog.yesNo ("Replace the existing " + resType + " with new code?") {
						adrObject^ = resData;
						table.gotoAddress (adrObject)}};
				return (true)};
			if not loadType (path, 'UCMD') {
				return (false)};
			if not loadType (path, 'XCMD') {
				return (false)};
			if not loadType (path, 'XFCN') {
				return (false)}}};
	Frontier.finderToFront = false;
	loadFrom (path);
	if not foundAtLeastOne {
		scriptError ("There are no UCMDs, XCMDs or XFCNs in file \"" + file.fileFromPath (path) + "\".")}}

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.