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


on findSiteInfo (siteurl, adradrinfo, adrcreatecallback=nil, {
	<<Find a siteinfo table, based on its URL. Call adrcreatecallback^ if the siteinfo table doesn't exist.
	bundle { //make sure the siteUrl includes the port
		local (parts = string.urlSplit (siteUrl));
		if not (parts[2] contains ":") {
			parts[2] = parts[2] + ":80"};
		siteUrl = parts[1] + parts[2] + "/" + parts[3]};
	local (adrinfo = @adrtable^.[siteurl]);
	if defined (adrinfo^) {
		while typeOf (adrinfo^) == addressType {
			adrinfo = adrinfo^};
		adradrinfo^ = adrinfo;
		return (true)};
	if adrcreatecallback != nil {
		if adrcreatecallback^ (adrinfo) {
			adradrinfo^ = adrinfo;
			return (true)}
		else {
			try {delete (adrinfo)}}};
	return (false)};

<<bundle //testing
	<<local (adr)
	<<if findSiteInfo ("", @adr)
		<<dialog.notify (adr)
		<<speaker.beep ()

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.