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

File Operations

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

Case Conversation Algorithm

Keywords:    Case Conversation	upper lower case uppercase lowercase

Question:

I'm trying to come up with a case-conversion routine.

I have a client with an application that produces a text file (1k to 4k in size) in all UPPER case. They need to convert to UPPER/lower case for easier processing for FTP to the web.

Any suggestions?

Answer:

Ummm Tricky. I would first of all convert it to all lower case - as most normal text is lower case, they parse it to figure out what has to be upper case.

The first character is uppercase - beginning of a sentence. The first character after a period is also uppercase - also beginning of a new sentence.

They you need a list of words that appear in the document that are supposed to be uppercase.

I've attached some code I use for titles... It takes wrong cased titles and tries to automagically assign the correct case to it.

Titles have different rules for capitalization than straight text. The code does one line at a time. A line is passed in the variable "CAPLINE" and the recased text is returned in the same line...

;========================cut============================================== 
:capit
dddd=Debug(0)

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


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)
Debug(dddd)
return

Article ID:   W13222
Filename:   Case Conversion Algorithm.txt
File Created: 1999:04:15:16:52:34
Last Updated: 1999:04:15:16:52:34