Monday, November 08, 2010 at 12:02 AM.
system.verbs.builtins.file.fileToURL
on fileToURL (f) { <<Changes <<8/10/08; 8:10:31 PM by DW <<Simplified. <<Old code... <<local (s = "file://") <<local (pc = file.getPathChar ()) <<local (i, field, ctfields = string.countFields (f, pc)) <<for i = 1 to ctfields <<field = string.nthField (f, pc, i) <<if sys.os () beginsWith "Win" <<if i == 1 <<field = field - ":" <<s = s + "/" + field <<if file.exists (f) <<if file.isFolder (f) <<s = s + "/" <<return (s) return ("file:///" + string.replaceall (f, file.getpathchar (), "/"))} <<bundle <<test code <<webbrowser.openurl (filetourl ("Macintosh HD:Users:davewiner:Desktop:Podcatcher:test1:cn08jul25.mp3")) <<dialog.alert (fileToURL (websites.["#data"].f)) <<dialog.alert (fileToURL (frontier.getprogrampath ()))
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.