WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

String Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

String Capitalization


#DefineFunction IntelliCaps(capline)
          til=ItemCount(capline,"~")
          If til > 1
              spcapline=""
              For xx=1 To til
                 thisline=ItemExtract(xx,capline,"~")
                 thisline=Intellicaps(thisline)
                 spcapline=StrCat(spcapline,thisline)
                 If xx != til Then spcapline=StrCat(spcapline,"~")
              Next
              Return (spcapline)
          EndIf

          CapLine=StrTrim(StrLower(CapLine))
          CapCount=ItemCount(CapLine," ")
          NewCapLine=""
          For capxx=1 To CapCount
             cw=ItemExtract(capxx,CapLine," ")
             If capxx==1 || ( capxx!=1 && cw!='a' && cw!="an" && cw!='to' && cw!='by' && cw!='the' && cw!='for' && cw!='and' && cw!='in' && cw!='about' && cw!='on' && cw!="of" && cw!="from" && cw!="with" && cw!="my" )
                If StrLen(cw) >= 2
                    charone=StrUpper(StrSub(cw,1,1))
                    If charone=="'" || charone=='"' || charone=="`"
                       cw=StrCat ( StrUpper(StrSub(cw,1,2)) , StrSub(cw,3,-1))
                    Else
                       cw=StrCat ( charone , StrSub(cw,2,-1))
                    EndIf
                Else
                   If StrLen(cw==1) Then cw=StrUpper(cw)
                EndIf
             EndIf
             cw2=StrReplace(cw,".","")
             cw2=StrReplace(cw2,",","")
             If cw2=="Bc" || cw2=="Ad" || cw2=="Ii" || cw2=="Iii" || cw2=="Iv" || cw2=="Vi" || cw2=="Vii" || cw2=="Viii" || cw2=="Ix" Then cw=StrUpper(cw)
             Newcapline=StrCat(newcapline,cw," ")
          Next
          CapLine=StrTrim(newcapline)

            Return (capline)
#EndFunction

;Tests


x="If Anyone Gets Out Of Here alive"
y=Intellicaps(x)
Message(x,y)

x="Did You See The Green, Green Grass"
y=Intellicaps(x)
Message(x,y)

x="O'eg R'eouvre~An Ounce with Pounce"
y=Intellicaps(x)
Message(x,y)

Article ID:   W17285
File Created: 2007:07:03:14:29:20
Last Updated: 2007:07:03:14:29:20