Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper Case 2

Status
Not open for further replies.

lindss

Instructor
Apr 27, 2005
6
US
I am using CR 8.5 which doesn't have the proper case function. I got a formula from Ngolem from a thread dated June 5 2003. (See below) When I apply this formula to a name such as "THOMAS SMITH" the result is "Thomas S Smith." For some reason, it is making the first letter of the last name a middle initial. My name strings do not have middle initials. Otherwise, it is doing everything else ok. Can anyone help? Thanks.


StringVar Original := {table.string};
NumberVar Temp;
numberVar SPointer := 1;
numberVar EPointer := length(Original);

//take care of the first CAP
Original := uppercase(left({table.string},1)) +
lowercase(right({table.string}, length({table.string}) - 1));

While SPointer < EPointer do
(
Temp := inStr(SPointer,original," ");
if Temp > 0 then
(
Original := left(Original,Temp) +
uppercase(mid(Original,temp+1,1)) +
Right(Original,EPointer - temp+1);
SPointer := Temp + 1;
)
else
(
SPointer := EPointer ;
);
);

Original;
 
The problem is in the Right function, That takes the right most characters from a string, so it can't work as written. I prefer a mid function instead

Original := left(Original,Temp) +
uppercase(mid(Original,temp+1,1)) +
mid(Original,temp+2);

is the correct line.

Editor and Publisher of Crystal Clear
 
The following should work for names with no middle initials, as long as they don't contain variations like McDaniels or van Holland etc.

ucase(left({@string},1)) +
lcase(mid({@string},2,instr({@string}," ")-1))+
ucase(mid({@string},instr({@string}," ")+1,1))+
lcase(mid({@string},instr({@string}," ")+2))

There is a UFL for leading caps that you can download from Business Objects, which might be the best way to go.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top