Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Custom Capitalize Function

From: louisaturk:eudoramail at: 24-May-2002 20:50

At 11:13 AM 5/25/2002 +1200, you wrote:
>Try... > >capitalize-it: function [a [string!] b [string!]][found][ > if not found: find/tail find/tail a " " " " [return] > if all [found/1 >= #"A" found/1 <= #"Z"] [ > if not found: find/tail find/tail b " " " " [return] > if all [found/1 >= #"a" found/1 <= #"z"] [ > change found to-char to-integer found/1 - 32 > ] > ] >] > >Seems to work... > > >> a: "a b c" b: "x y z" capitalize-it a b >== none > >> a >== "a b c" > >> b >== "x y z" > >> a: "a b C" b: "x y z" capitalize-it a b >== "" > >> a >== "a b C" > >> b >== "x y Z" > >If you're sure all your strings will have two spaces in you could take >out the checks for that. ie, remove the "if not" and "[return]" from >the two lines where the strings are searched.
So far it works great! I'll be testing it extensively over the next few weeks. No news will mean it works and no bugs. Many thanks. Your code complete a script that is very important to me. Louis