Thursday, February 24, 2011 at 12:01 AM.
system.verbs.builtins.string.addPeriodToSentence
on addPeriodToSentence (s) { <<Changes <<2/23/11; 10:50:17 PM by DW <<Don't add a period at the end of the sentence if there is already one there. <<5/20/10; 8:13:24 AM by DW <<Ending with a punctuation mark is not the right test -- a sentence that ends with a right-square-bracket still needs a period. So we narrow the test to a small set of characters. <<5/20/10; 7:01:54 AM by DW <<Created. It looks stupid to add a period at the end of a sentence that already ends with a punctuation mark. So we only add one if the last character is not a punctuation mark. local (sizes, ch); s = string.trimwhitespace (s); sizes = sizeof (s); if sizes > 0 { ch = s [sizes]; if (ch != '!') and (ch != '?') and (ch != '.') { s = s + ". "} else { s = s + " "}}; return (s)} <<bundle //test code <<dialog.alert (addPeriodToSentence ("Oh the buzzing of the bees")) <<dialog.alert (addPeriodToSentence ("Oh the buzzing of the bees!")) <<dialog.alert (addPeriodToSentence ("Oh the buzzing of the bees]"))
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.