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

system.verbs.builtins.html.directory.popUri

on popuri (uri, levels) {
	on skiptosquiggle (i) {
		local (j);
		for j = i - 1 downto 1 {
			<<msg (string.mid (uri, 1, j))
			if uri [j] == "~" {
				return (j - 1)}}};
	local (i, ct = 0, flskip, sizeuri = sizeof (uri));
	if levels == 0 {
		return (uri)};
	i = sizeuri;
	if uri [i] == "~" {
		i = skiptosquiggle (i)};
	loop {
		if i < 1 {
			return ("")};
		<<msg (string.mid (uri, 1, i))
		if uri [i] == "/" {
			if ++ct == levels {
				return (string.mid (uri, 1, i - 1))};
			i--;
			if i < 1 {
				return ("")};
			<<msg (string.mid (uri, 1, i))
			if uri [i] == "~" {
				i = skiptosquiggle (i)}}
		else {
			i--}}};
bundle { //test code
	<<dialog.alert (popuri ("theWeb/development/contentManagement/~4/userland/software/frontier~", 2))
	dialog.alert (popuri ("theWeb/development/contentManagement", 2))}



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.