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

system.verbs.apps.FinderMenu.commands.findInFile

local (notfound = true);
local (searchcancelled = false);
local (searchstring);
local (openedsomething = false);

on findInFolder (folder) {
	fileloop (f in folder) {
		if file.isFolder (f) {
			if not findInFolder (f) {
				return (false)}}
		else {
			rollBeachBall ();
			msg (file.fileFromPath (f));
			if file.findInFile (f, searchstring) {
				notfound  = false;
				s = "The search string “" + searchstring + "” was found in “" + file.fileFromPath (f) + "”.";
				s = s + " Would you like to open the file?";
				case dialog.yesNoCancel (s) {
					1 { <<Yes
						launch.anything (f);
						openedsomething = true};
					3 { <<Cancel
						searchCancellled = true;
						return (false)}}}}};
	return (true)};

if not dialog.ask ("String to search for?", @FinderMenu.commands.searchstring) {
	return};
searchstring = FinderMenu.commands.searchstring;

on visit (path) {
	local (folder = path);
	if not file.isFolder (path) {
		folder = file.folderFromPath (path)};
	return (findInFolder (folder))};
FinderMenu.visitPaths (@visit);

msg (""); <<restore Frontier's main window
if (not searchCancelled) and (not openedsomething) {
	if notfound {
		dialog.alert ("“" + searchstring + "” not found.")}
	else {
		dialog.alert ("Search complete.")}}



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.