Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.string.popTrailingFilename
on popTrailingFilename (s, delimiter="/") { <<Changes <<1/25/01; 12:08:57 PM by DW <<Created. Given a string, a url or a filepath, scan from the end looking for the delimiter, and return all the characters to the left of the delimiter, including the delimeter. <<For example, take foo/baz/bar.html and return foo/baz/. <<This is useful when you want to save a file in the same folder as another file. local (i); for i = sizeof (s) downto 1 { if s [i] == delimiter { return (string.mid (s, 1, i ))}}; return (s)} <<bundle //test code <<dialog.alert (popTrailingFilename ("http://www.scripting.com/index.html"))
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.