Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Uppercase first character of each word

Keywords:   Uppercase first character of each word

Question:

Does anyone have a way to convert strings into a propercase string? For example: "tHis sTRing is Jacked" into "This String Is Jacked"

Answer:

Umm. What is the definition of ProperCase being used here.

It it is take string. Uppercase first character of each word. Lowercase remainder of word... then maybe...




;This Udf Converts A String From Random Mixed Case To "propercase" Where
; Only The First Words Of Strings Are Uppercase And The Rest Are Lowercase

;More advanced versions are loating around that understand quoted words,
;some words that do not get capitalized like the or of in strings,
;roman numerals, and common abbreviations. However all of those are
;very usage and language dependent.

#DefineFunction Propercase(sbad)
sbad=StrLower(sbad)
count=ItemCount(sbad," ")
sgood=""

For xx=1 To count
thisword=ItemExtract(xx,sbad," ")
thislen=StrLen(thisword)
If thislen > 1
thisword=StrCat(StrUpper(StrSub(thisword,1,1)),StrSub(thisword,2,-1))
Else
If thislen==1
thisword=StrUpper(thisword)
EndIf
EndIf
If sgood=="" Then sgood=thisword
Else sgood=StrCat(sgood," ",thisword)
Next
Return(sgood)

#EndFunction



TestString="tHis sTRing is Jacked"
FixedString=ProperCase(TestString)
Message(teststring,FixedString)