Microsoft Small Basic

Program Listing: VQL120
' SmallBasic Version 1.2
' Program: CapitalizeWords
' Changelog:
' Author: Pappa Lapub
' Website: https://social.msdn.microsoft.com/Forums/en-US/82e661f8-5189-4aa5-9f7f-6f5d7965e744/challenge-of-the-month-march-2018
' ImportURL: http://smallbasic.com/program/?
' Extension: ---
' Comment:
'
' Variables:
' ToDo:
' ================================================================================
tab = Text.GetCharacter(9)
lf = Text.GetCharacter(10)
crlf = Text.GetCharacter(13) +lf

elseLow = "True" ' all other chars to LowerCase? "True" or "False"
reverse = "False" ' reverse whole text? "True" or "False"
txt = "statistics Is lIKe a bikini:"+ tab +"everyThiNG inSIGnificant iS vIsIbLe,"+ lf +"buT the interesTING aNd decisivE"+ crlf +"reMAInS hIdDeN."

TextWindow.WriteLine(txt +lf+lf +"-->"+ lf)
len = Text.GetLength(txt)
ws = "1=9;2=10;3=13;4=32;" ' 5=133;6=160;..."

For n = 1 To len
chr = Text.GetSubText(txt, n,1)
If n = 1 Or Array.ContainsValue(ws, Text.GetCharacterCode(Text.GetSubText(txt, n-1,1))) Then
chr = Text.ConvertToUpperCase(chr)
ElseIf elseLow Then
chr = Text.ConvertToLowerCase(chr)
EndIf

If reverse Then
str = Text.Append(chr, str)
Else
str = Text.Append(str, chr)
EndIf
EndFor
TextWindow.WriteLine(str +lf)